TTYSER page# 0001 next
2: COMMENT ⊗   VALID 00087 PAGES
3: C REC  PAGE   DESCRIPTION
4: C00001 00001
5: C00006 00002    BEGIN TTYSER - SCANNER, KEYBOARD AND CONSOLE TELETYPE SERVICE ROUTINE
6: C00008 00003    DATA STRUCTURES AND PARAMETERS
7: C00011 00004    IOS BITS
8: C00014 00005    LINE BITS, LINE # DEFS
9: C00017 00006    AC'S, BYTE POINERS, CTLV
10: C00019 00007    LINBIT, TTYINI
11: C00024 00008    MORE TTYINI, SCNINI
12: C00027 00009    TTYCOM, TTYCM, CNTCOM, COMBCK
13: C00034 00010    TTYATI, TTYSUB
14: C00037 00011    TTYSUB TABLES
15: C00038 00012    FILL, ECHO, FULL, TABS, TIME, WHO
16: C00044 00013    TTYATT
17: C00047 00014    TTYDET, TRESCN, TRESCU
18: C00050 00015    TBYTEP
19: C00051 00016    TTYGET, TTYFNU, TTYFND, TTYFUW, TTYERP, TTYERR
20: C00054 00017    TTYSET, TTYSTC
21: C00055 00018    TTYSTR, TTYUSR
22: C00057 00019    TTYTLK
23: C00061 00020    TTYSRC, STLNAC
24: C00063 00021    GETDDB, LOG2LN
25: C00065 00022    DDBSRC, STDTBL
26: C00069 00023    SCNIN
27: C00071 00024    TTYSKL, TTYREL, TTYKIL
28: C00076 00025    MORE TTYKIL
29: C00080 00026    OUTCH6, OUTCHS, OUTCHR
30: C00084 00027    MORE OUTCHR  ADJHP
31: C00087 00028    PUTCHI, PUTCHO
32: C00091 00029    GETCHR, GETCHY
33: C00093 00030    GETCHA, GETCHO
34: C00095 00031    TSETBF, SETBFI, SETBF3, SETBFO
35: C00097 00032    SPCHEK, SPCACT
36: C00100 00033    SPCTAB
37: C00103 00034    TTYUUO, CLRBUF, INSKIP
38: C00106 00035    INCHSL, INCHRS, INCHWL, IWAIT, OUTSTR, INCHGT, INCHGB
39: C00110 00036    INCHRW, ONEOUT, GETLIN, SETLIN, SYNCHK, SYNCHA, SETACT
40: C00117 00037    OUTFIV, FIVOUT
41: C00120 00038    TTYMES
42: C00124 00039    TTREAD, TTYJNO, TTYJOB
43: C00127 00040    SNEAKS, SNEAKW, ACTCHR
44: C00130 00041    DDTIN
45: C00133 00042    DDTOUT, DDTWAT
46: C00135 00043    SCNDSP, TTYIN, TWSYNC, TTYSKP
47: C00138 00044    MONUSR
48: C00142 00045    TTYOUT
49: C00144 00046    USRMON
50: C00147 00047    SCNIN1, SCNTYP, KBDINT
51: C00150 00048    SHFTBL, CONVTB
52: C00152 00049    DKBINT
53: C00155 00050    DKBTBL
54: C00157 00051    SCNINT
55: C00158 00052    CTYINT
56: C00159 00053    RECINT, RECINA, RECINB, RECINC, RECIM3, NOESC, ESCRET
57: C00165 00054    RECIN3, RECIN4, UTYPET, TYPTST, TYPGO, TTINT
58: C00170 00055    ESCAPE BITS
59: C00171 00056    SETESC
60: C00174 00057    DOESC
61: C00176 00058    SPESC
62: C00177 00059    ESCAPES
63: C00179 00060    MORE ESCAPES    VDESET  VDECHK  VDVCHK
64: C00182 00061    ASSCN, ASESC, ESCB  AUDIO SWITCH SERVICE
65: C00190 00062    PKINT   PAGING INTERRUPT SERVICE ROUTINE
66: C00194 00063    ADSMAP, BEEP UUOS
67: C00206 00064    RECIML
68: C00207 00065    TYPX, COMSET
69: C00209 00066    TTEDIT
70: C00213 00067    TTIPUT, DUPLEX, DUPLX1, INBFUL
71: C00216 00068    CONTC, CONTOB, CONTO, CONTB, ALTMOD, TTYUNH
72: C00220 00069    RUBOUT, AOJDPX, CONTK, CONTL
73: C00222 00070    CONTI, CONTP
74: C00225 00071    CRLFEC, CRLF
75: C00227 00072    CNCTST, CNCMOD
76: C00229 00073    BSECHO, DCPUTR, DELETL
77: C00231 00074    DOTALK, NOTALK
78: C00237 00075    XMTINT, XMTIN1, DPYSTR, DPYDON
79: C00240 00076    XMTIN4, XMTIN2, LINDON, TTYPE
80: C00243 00077    TYP, TYPL, CTYP
81: C00245 00078    PTYGET, PTOCK, PTICHK, PTYCLR
82: C00249 00079    PTYUUO, LINMAP, PTOCNT, PTIFRE
83: C00252 00080    PTYREL, PTRD1S, PTRD1W, PTWAIT
84: C00255 00081    PTWR1S, PTLL3, PTWR1W, PTRDS, PTWRS7, PTWRS9
85: C00259 00082    PTJOBX
86: C00261 00083    PTJHLT, PTJCON, PTIWTS, PTCLRB
87: C00264 00084    PTDON, PTDOFF,PTLOGN,IMLOAD
88: C00267 00085    PHONE DIALER LIVES HERE
89: C00269 00086    DIAL UUO
90: C00275 00087    DIALER INTERRUPTS COME HERE
91: C00278 ENDMK
92: C⊗;
    TTYSER page# 0002 next  prev
94: BEGIN TTYSER - SCANNER, KEYBOARD AND CONSOLE TELETYPE SERVICE ROUTINE
95: SUBTTL TTYSER - -DEC MOD D. POOLE MOD R. HELLIWELL
96: 
97: 
98: 
99: 
100: ;SCNSER IS ORGANIZED(?) INTO THE FOLLOWING SECTIONS
101: 
102: ;       I.      COMMENTARY ON OPERATION AND DATA STRUCTURES
103: ;      II.      SYSTEM INITIALIZATION ROUTINE - SCNINI
104: ;      III.     COMMAND LEVEL ROUTINES
105: ;                       A. TTYATT
106: ;                       B. TTYCOM
107: ;                       C. TTYDCM
108: ;                       D. TTYDET
109: ;                       E. TTYFND,TTYFNU
110: ;                       F. TTYKIL
111: ;                       G. TTYSET
112: ;                       H. TTYSRC
113: ;                       I. TTYSTR
114: ;                       J. TTYTLK
115: ;                       K. TTYUSR
116: ;     IV.       UUO LEVEL ROUTINES
117: ;                       A. DDTIN
118: ;                       B. DDTOUT
119: ;                       C. TTYUUO
120: ;                       D. TTYIN
121: ;                       E. TTYOUT
122: ;       V.      INTERRUPT SERVICE ROUTINES
123: ;                       A. CTYINT
124: ;                       B. SCNINT
125: ;                       C. RECINT - ALL LINES RECEIVER INTERRUPT
126: ;                               1. TTEDIT - EDITS AND ECHOS
127: ;                       D. XMTINT -  TRANSMIT INTERRUPT
128: ;                               1. GETCHR
129: ;                               2. TYP
130: ;       VI.     PSUEDO-TELETYPE SERVICE ROUTINES
131: ;                       A. PTYGET
132: ;                       B. PTYCLR
133: ;                       C. PTYUUO
    TTYSER page# 0003 next  prev
135: ;DATA STRUCTURES AND PARAMETERS
136: 
137: ;       DEFINED ON CONFIGURATION TAPE
138: ;               SCNLIN=OCTAL NO. OF SCANNER LINES (0 THRU SCNLIN-1)
139: 
140: ;       DEFINED BELOW
141: ;               TRANSLATOR TABLE PARAMETERS
142: ;               TTYLEN=SCNLIN+DPYNUM+1  LENGTH OF TTY TRANSLATOR TABLE (INCLUDING CTY)
143: ;               TTYTAB: BLOCK TTYLEN    TTY TRANSLATOR TABLE
144: ;                       SIGN BIT=1 IF COMMAND JUST TYPED
145: ;                       BIT 1 = 1  IF DELAYED COMMAND
146: ;                       BITS 3-10 = UNUSED
147: ;                       BITS 11-17=TALK RING LINE # (PTALK)
148: ;                       BITS 18-35=ADDR. OF DEVICE DATA BLOCK 
149: ;                               FOR THIS LINE.
150: ;               DEVOPR: 0       SIXBIT PHYSICAL NAME OF OPERATORS
151: ;                               CONSOLE SET BY SCNIN0 TO FIRST
152: ;                               ACTIVE TTY.
153: 
154: ;       DEFINED BELOW
155: ;               LINE NUMBER PARAMETERS
156: ;               TCONLN=SCNLIN   CTY LINE NUMBER
157: ;               MTTYLN=-TTYLEN  -LENGTH OF TRANSLATOR TABLE
158: ;               FSNCHN=SCNCHN*101       CHANNEL ASSIGNMENT FOR
159: ;                               FULL DUPLEX SCANNER
160: ;               TTYLST=TTY0DB   FIRST TTY DEVICE DATA BLOCK
161: 
162: ;TTY DEVICE DATA BLOCK FORMAT
163: 
164: ;THE FOLLOWING ARE DEFINITIONS OF THE RELATIVE LOCATIONS OF THE
165: ;BUFFER PARAMETER WORDS OF THE DEVICE DATA BLOCK FOR EACH BUFFER, WITH
166: ;TTX'BUF AS THE BASE (DETAILED DESCRIPTIN IN SCNDDB COMMENTS):
167: 
168:         XP      BUF,0           ;BUF(DAT) CONTAINS POINTER TO BEG. OF CURRENT BUFFER
169:         XP      PUTR,1         ;PUTR(DAT)-PUTS CHARCTERS INTO BUFFER
170:         XP      PCTR,2          ;NUMBER OF TIMES TO INCR. PUTR BEFORE REINITING
171:         XP      TAKR,3         ;TAKER POINTER TO PICK UP CHARACTERS
172:         XP      TCTR,4          ;COUNT OF NUMBER OF TIMES TAKR CAN BE INCREMENTED
173:         XP      FCTR,5         ;COUNT OF FREE SPACES LEFT IN BUFFER
174:         XP      TSYNC,6         ;LOCATION OF TISYNC RELATIVE TO DAT
175: 
176: 
177: ;               DEVNAM: PHYSICAL DEVICE NAME SET UP DYNAMICALLY
178: ;                       VIA SCNIN0.
179: ;               DEVCHR: LEFT HALF IS STANDARD
180: ;                       BITS 18-24=LINE NUMBER(BYTE POINTER=PUNIT)
181: ;                       BITS 25-35=MONITOR BUFFER SIZE + 1(BYTE POINTER=PDVBLN)
    TTYSER page# 0004 next  prev
183: ;IOS BITS
184: ;               DEVIOS: LEFT HALF
185: ;                       1,2,4,20,40 ARE STANDARD
186:                         USRB←←100      ;SET TTY TO USER MODE
187:                                         ;WHEN OUTPUT FINISHES
188:                                         ;TILL NEXT INPUT OR INIT (↑O).
189:                         TPMON←←400     ;TTY IS IN MONITOR
190:                                         ;COMMAND MODE.
191:                         DDTM←←1000      ;DDT MODE
192:                         ↑↑TTYDTC←←2000  ;TTY DDB IS DETACHED FROM LINE
193:                         TOIP←←10000    ;TYPE-OUT IN PROGRESS
194:                                         ;TAKER IS BEHIND PUTR
195:                         SYNC←←20000     ;BREAK CHARACTER SEEN
196:                                         ;SIGNAL TO INCREMENT SYNC COUNT
197:                                         ;FOR BUFFER INVOLVED
198:                         IMLTTY←←40000   ;IMLAC IS IN TTY MODE FOR NEXT CHARACTER
199:                         TTYHLD←←100000  ;TYPEOUT HOLD (BO)
200:                         SNKWAT←←200000  ;SNEAK PREVIEW WAIT FLAG!
201:                         TTYIOW←←400000  ;TTY INPUT WAIT BIT
202: 
203: ;               RIGHT HALF BITS (USER MODE)
204:                         IOSUPR←←1000    ;SUPPRESS ALL OUTPUT
205:                         BKSP←←100       ;FULL CHARACTER SET. PASS
206:                                         ;ON ALL CHARACTERS EXCEPT ↑C
207:                                         ;NO SPECIAL CHARACTER PROCESSING
208:                         NOECHO←←200     ;ECHO SUPPRESSION REQ BY PROG
209:                         NOECHB←←400     ;SUPPRESS ECHO OF CTRL BITS
210:                         MERTP1←←2000    ;DURING ERROR TYPEOUT THIS MEANS
211:                                         ;THE INPUT BUFFER IS IN USE.
212:                         MERTPO←←IOIMPM  ;MONITOR ERROR TYPE-OUT
213: ;               DEVSER: STANDARD
214: ;               DEVBUF: STANDARD
215: ;               DEVIAD: BITS 6-12=HORIZONTAL POSITION (BYTE
216: ;                               POINTER = PHPOS).
217: ;                       BITS 13-35 ARE STANDARD.
218: ;               DEVOAD: BITS 0-8=NUMBER OF CHARACTERS TO FIT
219: ;                               ;INTO OUTPUT BUFFER
220: ;                               (POINTER= PFITCH)
221: ;                       BITS 13-35 ARE STANDARD
222: IFNDEF FTDDTM,<FTDDTM←←-1>      ;NON-ZERO TO INCLUDE CALLI DDTIN,OUT
    TTYSER page# 0005 next  prev
224: ;LINE BITS, LINE # DEFS
225: ;DEFINITION OF LINE CHARACTERISTICS TABLE BITS
226: ;LINTAB MADE BY SYSTEM BUILDER
227: ;FOLLOWING IS FORMAT AS SET UP BY SCNINI
228: ;       XWD BITS,LOGICAL LINE#
229: 
230: DISLIN←←400000                 ;THIS LINE IS TO A DISPLAY KEYBOARD
231: CTYLIN←←200000                 ;THIS "LINE" IS CONSOLE DEVICE "TTY"
232: TTYFIL←←100000                  ;THIS LINE IS IN "FILL" MODE
233: DDDLIN←←20000                  ;DATA DISK DISPLAY LINE
234: M37←←10000                      ;MODEL 37 TTY
235: PTYLIN←←4000   ;PSEUDO-TTY.
236: IMLIN←←2000                     ;THIS IS AN IMLAC
237: 
238: APLINE←←12                      ;LINE # OF AP LINE
239: IMSSS←←7                        ;SUPPES
240: 
241:         ;ABOVE ARE "PERMANENT" CHARACTERISTICS
242: 
243: TLKRNG←←1                      ;THIS LINE CURRENTLY IN A TALK RING
244: XON←←2                          ;↑Q TYPED, PAPER TAPE INPUT
245: FULTWX←←4                       ;SELF ECHOING FUL DUPLEX
246: TBXPND←←10                      ;EXPAND TABS (SOMETIMES PERMANENT SOMTIMES CHANGEABLE)
247: FCS←←20                         ;FULL CHAR SET MODE
248: ROBTPD←←40                      ;RUBOUT TYPED LAST (ECHO \ BEFORE NEXT CHAR.)
249: SPCBRK←←100     ;SPECIAL ACTIVATION MODE... EVERYTHING EXCEPT LETTERS AND NUMBERS IS A  BREAK CHAR.
250: PTYUSE←←200     ;;PTY LINE IN USE... DO NOT KILL DDB AT TTYKIL.
251: PTYWAK←←400             ;SAYS PTY INPUT WAIT MAY BE TERMINATED BY TTY INPUT.
252: IMPBIT←←1000                   ; THE GUY ON THE OTHER END OF THIS PTY IS AN IMP
253: LERSEE←←40000   ;USER WANTS TO SEE EVERYTHING TYPED TO
254:                 ; DPY LINE EDITOR DURING RE-EDITS. SEE LINED.
255: 
256: 
257: ;ABOVE ARE TEMPORARY BITS, TURNED ON AND OFF BY VARIOUS MEANS
258: ;(BY MONITOR, TYPE-IN COMMANDS, OR PROGRAM)
259: 
260:                 ;BITS BELOW CAN BE SET OR ZEROED BY PROGRAM
261: LGLSET←←TBXPND!TTYFIL!FCS!XON!SPCBRK!PTYWAK!IMPBIT!FULTWX!LERSEE
262: KILMSK←←ROBTPD!TLKRNG!XON!SPCBRK!PTYLIN!PTYWAK!IMPBIT!LERSEE    ;CLEARED AT TTYKIL
263: 
264: ; THESE ARE INSERTED HERE BECAUSE THEY AREN'T DEFINED ANYWHERE ELSE
265: ; IN THIS SYSTEM
266: 
267: GLOBAL TTPLEN   ;STUPID FAIL
268: MTTYLN←←-TTPLEN         ; MINUS NUMBER OF TELETYPES, TOTAL
269: TCONLN←←SCNNUM+DPYNUM+DDNUM
270: PTYL0←←TCONLN+1                ;FIRST PTY LINE NO.
271: DPYL0←←SCNNUM
272: DDL0←←DPYL0+DPYNUM
273: FSNCHN←←SCNCHN*101              ; SCANNER PI CHANNEL ASSIGNMENTS
274: 
    TTYSER page# 0006 next  prev
276: ;AC'S, BYTE POINERS, CTLV
277: ;ACCUMULATOR ASSIGNMENTS
278: 
279:         CHR←TEM         ;AC FOR CHARACTER
280:         LINE←TAC1               ;SCANNER LINE NUMBER
281:         HPOS←ITEM               ;HORIZONTAL POSITION OF TTY.(0-71)
282: 
283: 
284:         ;SPECIAL SYMBOLS
285: 
286:         SCNON←←1B25!1(7-SCNCHN)
287:         SCNOFF←←1B26!1(7-SCNCHN)
288: 
289:         IDLECH←←1               ;DELAY CHAR FOR TABS, ETC.
290:                                 ; SHOULD BE ↑V, BUT FOR 37'S
291: 
292: 
293: ;BYTE POINTERS
294: 
295: PFITCH: POINT 9,DEVOAD(DDB),8           ;NR OF CHARACTERS TO FIT
296: PHPOS:  POINT 7,DEVIAD(DDB),12  ;HORIZONTAL POSITION
297: 
298: IFN FTTALK,<
299: PTALK: POINT PUNITS,TTYTAB(LINE),17    ;POINTER TO ANOTHER TTY IN TALK RING
300:                                         ;(SAME SIZE BYTE AS SYS UNIT #)
301: >
302: 
303: 
304: PLASTC:
305:         POINT 7,TTYPTR(DDB),35  ; FOR ECHO CHECKING ON HDX LINES
306: PCOMIC:
307:         POINT 9,TTYPTR(DDB),19  ; FOR RESCANNING COMMAND INPUT LINE
308:                                 ;"COMMAND INPUT COUNTER" SAVES TITCTR
309: PLSTLC: POINT 9,TTYPTR(DDB),28  ;FOR ↑U DELETION
310: 
311: ;TTYPTR CONTAINS THE FOLLOWING BYTES:
312: ;
313: ;       0-3     SPARE
314: ;       4-10    PTYJOB, FOR NO. OF JOB OWNING THE PTY (IF ANY) USING THE DDB.
315: ;       11-19   PCOMIC, FOR COMMAND RESCAN
316: ;       20-28   PLSTLC, FOR ↑U
317: ;       29-35   PLASTC, FOR ECHO CHECKING HALF DUPLEX LINES
318: 
319: CTLV1: PUSHJ P,TTYFNU
320:         MOVEI IOS,NOECHO
321:         XORM IOS,DEVIOS(DDB)
322:         POPJ P,
    TTYSER page# 0007 next  prev
324: ;LINBIT, TTYINI
325: ;SCNINI IS CALLED AT SYSTEM INITIALIZATION TIME FROM
326: ;IOGO IN SYSINI VIA DISPATCH TABLE
327: ;IT     1)CLEARS ALL RECEIVER FLAGS,
328: ;       2)CLEARS THE PHYSICAL NAME (DEVNAM) OF ALL UNUSED
329: ;         (TTYUSE=0) TTY DEVICE DATA BLOCKS,
330: ;       3)SETS DEVIOS TO XWD TPMON+IOFST,0  IN ALL TTY DEVICE
331: ;         DATA BLOCKS,
332: ;       4)SETS TTYUSE=1 IN ALL TTY DDBS IN THE TRANSLATOR TABLE.
333: 
334: DEFINE BITS(X),<XWD X,.-LINBIT>
335: 
336: LINBIT: 
337: REPEAT 10,<BITS TBXPND!FCS
338: >                               ;0-7 ARE MODEL 33
339: REPEAT 2,<BITS TBXPND!FCS
340: >                               ;10,11 DATAPHONES
341: REPEAT 3,<BITS  TBXPND!M37!FCS
342: >                               ;12-14 ARE MODEL 37
343: REPEAT 3,<BITS  IMLIN!FCS
344: >                               ;15-17 ARE IMLACS
345: REPEAT DPYNUM,<BITS     DISLIN!FCS
346: >
347: REPEAT DDNUM,<BITS DDDLIN!FCS>
348:         BITS    CTYLIN
349: REPEAT PTYNUM,<BITS 0>          ;JUST IN CASE SOMEONE LOOKS HERE
350: ;END OF BIT TABLE
351: 
352: TTYINI:
353:         PUSHJ   P,DWPINI                ;LET JAM THROW AWAY THE DPY FREE STORAGE
354:                                         ;BEFORE WE DO OUR BUGEY!
355: IFN DILNUM,<PUSHJ P,DILINI>             ;INITIALIZE DIALER STUFF
356:         MOVSI   LINE,-TCONLN-1          ;REAL TTY'S ONLY
357: SCN0:   MOVE    TAC,LINBIT(LINE)        ;GET PERMANENT LINE CHARACTERISTICS
358:         HRRM    TAC,LINTAB(LINE)        ;SET LOG. LINE NUMBERS
359:         IORB    TAC,LINTAB(LINE)        ;SET SIGNIFICANT BITS
360:         TLZ     TAC,KILMSK              ;ZAP INSIGNIFICANT BITS
361:         HLLM    TAC,LINTAB(LINE)        ;LEAVING REST OF BITS AS THEY WERE
362:         AOBJN   LINE,SCN0
363: 
364:         CONO    CTY,3600!CTYCHN         ; CLEAR CTY, ASSIGN CHANNEL
365:         CONO    DKB,10!SCNCHN           ; CLEAR DDD TTY SCANNER AND ASSIGN CHANNEL
366:         PUSHJ   P,SCNINI                ;DEVICE DEPENDENT SCANNER INIT
367:         SETZM   TTYTAB
368:         SETZM   COMCNT                  ;NO COMMANDS TO PROCESS
369:         MOVE    TAC,[XWD TTYTAB,TTYTAB+1]
370:         BLT     TAC,TTYTAB+TTPLEN-1     ;CLEAR ALL DDB ADDRESSES
371:         MOVE    TAC,[TCONLN,,TTYLST]    ;INIT CTY TO USE DDB IN ALLDAT
372:         MOVEM   TAC,TTYTAB+TCONLN       ;  BH 5/6/74
373:         SETZM   PAGNOW
374:         SETZM   ASBTAB                  ;CLEAR ALL BEEP DURATIONS
375:         MOVE    TAC,[ASBTAB,,ASBTAB+1]
376:         BLT     TAC,ASBTAB+DPYNUM+DDNUM-1
377:         SKIPL   TTYLOK
378:         SKIPE   MAINTM
379:         JRST    NOASIN                  ;DON'T INIT AUDIO SW IF SYS NOT FOR REAL
380:         SETZM   ASTAB
381:         MOVE    TAC,[ASTAB,,ASTAB+1]
382:         BLT     TAC,ASTAB+DPYNUM+DDNUM-1
383: NOASIN: HRRZS   TTYLST+DEVSER           ;CLEAR DDB CHAIN
384:         SETZB   IOS,TTYLST+DEVIOS       ;SO DDB WILL GET FLUSHED
385: ;       MOVEI   DDB,TTYLST              ;2 LINES COMMENTED OUT BH 5/6/74
386: ;       PUSHJ   P,TTYKIL                ;HERE.
387:         MOVEI   ITEM,JOBN-1             ;REGENERATE DDB'S FOR ALL LIVE JOBS
388: SCNC1:  MOVE    TAC,JBTSTS(ITEM)
389:         TLNN    TAC,JNA                 ;IS THIS A JOB
390:         JRST    SCNC3                   ;NO, IGNORE HIM.
391:         HRRE    LINE,JBTLIN(ITEM)       ;GET LINE HE IS USING
392:         JUMPL   LINE,SCNC2              ;DETACHED LINE
393:         PUSHJ   P,DDBSRC                ;GET HIM A DDB
394:         JRST    SCNC3                   ;IF NO DDB AVAILABLE OR NO LINE OR DETACHED
395:         PUSHJ   P,TTYATI                ;ATTACH JOB
396:         TLNE    LINE,PTYLIN
397:         SKIPE   PTYJOB-PTYL0(LINE)      ;IS THIS PTY REALLY ATTACHED TO SOMEONE?
398:         JRST    SCNC3                   ;YES
399:         PUSHJ   P,TTYDET                ;NO, DETACH HIM.
400:         JRST    SCNC3                   ;NEXT PLEASE
401: SCNC2:  TLNE    TAC,JSEG                ;IS IT AN UPPER SEGMENT?
402:         JRST    SCNC3                   ;YES, NO DDB FOR HIM
403:         MOVNI   LINE,1                  ;YES, GET A DETACHED LINE
404:         PUSHJ   P,DDBSRC                ;GET DDB
405:         JRST    SCNC3
406:         DPB     ITEM,PJOBN
407: SCNC3:  SOJG    ITEM,SCNC1
    TTYSER page# 0008 next  prev
409: ;MORE TTYINI, SCNINI
410: ; HERE WE GET THE DDB'S FOR THE REST OF THE TTY'S (I.E., NOT
411: ; THE ONES ATTATCHED TO JOBS ALREADY).
412: 
413:         MOVSI   LINE,-TTPLEN+PTYNUM             ;SET DDB USE BITS FROM TRANSLATOR TABLE
414: SCN2:   MOVSI   IOS,600000
415:         ANDCAM  IOS,TTYTAB(LINE)                ;NO COMMAND WAITING !
416:         HRRZ    TAC,LINE
417:         CAIGE   TAC,PTYL0                       ;PTY LINE?
418:         JRST    NOTPTY
419:         SKIPN   TTYTAB(LINE)                    ;DOES HE HAVE A DDB
420:         JRST    SCN6
421:         HRLI    TAC,PTYLIN!PTYUSE!XON           ; MAGIC PTY BITS
422:         MOVEM   TAC,LINTAB(LINE)                ; INITIALIZE THIS PTY
423:         JRST    SCN3                            ; STUFF IN 0'S
424: SCN6:   SETZM   PTYJOB-PTYL0(LINE)
425:         SETZM   LINTAB(LINE)            ;CLEAR PTY BITS
426:         JRST    SCN3
427: NOTPTY: SKIPE   TTYTAB(LINE)            ; IS THERE A DDB ADDRESS THERE?
428:         JRST    SCN3
429:         SKIPE   TTYLOK
430:         CAIN    TAC,TCONLN
431:         CAIA
432:         JRST    SCN3
433:         PUSH    P,LINE
434:         HRRZ    LINE,LINE
435:         CAIL    LINE,DPYL0
436:         CAIL    LINE,DDL0+DDNUM
437:         CAIA
438:         JRST    SCN5                    ;FOR DPYS ONLY
439:         CAIE LINE,IMSSS
440:         CAIN LINE,APLINE
441:         JRST .+3                ;DON'T MAKE DDB (I.E. DON'T TYPE OUT) ON THESE LINES
442:         PUSHJ   P,DDBSRC                ;MAKE TTY DDB AND SET UP TTYTAB
443:         JFCL
444:         POP     P,LINE
445: SCN3:   AOBJN   LINE,SCN2
446:         SETZM LINSAV    ;SO INIT. MESSAGE WILL GET TO EVERYONE.
447:         POPJ P,         ;ALL DONE
448: 
449: SCN5:   POP     P,LINE
450:         JRST    SCN3
451: 
452: ;DEVICE DEPENDENT PORTION OF INITIALIZATION CODE
453: ;CALL:  MOVEI   TAC,CHANNEL NUMBER
454: ;       PUSHJ   P,SCNINI
455: 
456: SCNINI: MOVEI   TAC,100000
457:         CONO    DCSA,4010       ;RELEASE XMITTER, RECEIVER
458:         CONSZ   DCSA, 1000
459:         CONO    DCSA, 4000
460:         CONSZ   DCSA, 10
461:         DATAI   DCSB, LINE
462:         SOJG    TAC,.-4
463:         CONO    DCSA,FSNCHN     ;ASSIGN INTERRUPT CHANNELS
464:         POPJ    P,
    TTYSER page# 0009 next  prev
466: ;TTYCOM, TTYCM, CNTCOM, COMBCK
467: ;ROUTINE TO SETUP AC DDB TO ADDRESS OF TTY WHICH HAS TYPED A COMMAND
468: ;AC DAT TO BYTE POINTER TO OUTPUT BUFFER FOR COMMAND MESSAGES
469: ;AC ITEM TO JOB NUMBER TTY IS ATTACHED TO
470: ;CALL:  PUSHJ P,TTYCOM
471: ;       NONE FOUND
472: ;       AC'S SETUP
473: ;CALLED FROM COMMAND
474: 
475: TTYCOM:
476:         SKIPGE  LINE,LINSAV
477:         JRST    TTYCM1                  ;GIVE SOMEONE ELSE A CHANCE
478:         MOVSI   LINE,MTTYLN
479:         SKIPL   TAC,TTYTAB(LINE)
480: TTYCM1: AOBJN   LINE,.-1
481:         MOVEM   LINE,LINSAV
482:         JUMPG   LINE,CPOPJ
483:         HRRZ    DDB,TTYTAB(LINE)
484:         JUMPE   DDB,TTYCM2              ;IT HAPPENS!!!!
485:         MOVE    DAT,DEVMOD(DDB)
486:         TLNN    DAT,TTYATC              ;IS HE ATTACHED TO IT BY JOB?
487:         TRNN    DAT,ASSCON!ASSPRG       ;NO, ASSIGNED OR INITED TTY'S CAN'T TYPE COMMANDS
488:         JRST    .+2
489:         JRST    TTYCM2                  ;(THIS CAN'T HAPPEN (IT SAYS SO IN COMSET))
490:         MOVEI   DAT,TTIBUF(DDB)         ;SO GETCHR CAN BE CALLED FROM COMCON
491:         MOVE    LINE,TITCTR(DDB)
492:         DPB     LINE,PCOMIC             ;SAVE COMMAND INPUT COUNTER
493:         LDB     LINE,PUNIT              ;LINE NO.
494:         LDB     J,PJOBN                 ;JOB NO. TTY ATTACHED TO
495:         MOVSI   CHR,TTYATC
496:         TDNN    CHR,DEVMOD(DDB)
497:         MOVEI   J,0                     ;NO JOB ATTACHED TO THIS TTY
498:         TLNN    TAC,DLYBIT              ;IS THIS A DELAYED COMMAND?
499:         JRST    CPOPJ1                  ;NO, RETURN TO SCAN IT
500:         MOVSI   TAC,DLYBIT              ;INDICATE NO LONGER DELAYED COMMAND
501:         ANDCAM  TAC,TTYTAB(LINE)
502:         JRST    CPOPJ1                  ;RETURN TO COMMAND SCAN
503: 
504: TTYCM: MOVE    LINE,LINSAV             ;HERE WHEN COMMAND MUST BE DELAYED
505:         MOVSI   DDB,DLYBIT              ;INDICATE DELAYED COMMAND
506:         IORB    DDB,TTYTAB(LINE)
507:         PUSHJ   P,TRESCN                ;BACK UP TO START OF COMMAND
508:         MOVE    LINE,LINSAV             ;TRESCN HAS CALLED STLNAC
509:         JRST    TTYCM1                  ;LOOK FOR OTHER COMMAND TO PROCESS
510: 
511: TTYCM2: PUSHACS
512:         PUSH    P,DDB
513:         PUSH    P,LINE
514:         PUSHJ   P,DISMES
515:         ASCIZ   /COMMAND BIT SET AND NO DDB, OR TTY ASSIGNED: TTY /
516:         POP     P,TAC
517:         PUSHJ   P,DISLOC
518:         PUSHJ   P,DISMES
519:         ASCIZ   /, DDB= /
520:         POP     P,TAC   
521:         PUSHJ   P,DISLOC
522:         PUSHJ   P,DISCRLF
523:         POPACS
524:         MOVSI   DDB,COMBIT!DLYBIT       ;CLEAR THESE BITS!
525:         SOS     COMCNT                  ;FIX COMCNT
526:         ANDCAM  DDB,TTYTAB(LINE)
527: IFN FTTTYBUG,<
528:         PUSHJ   P,COMBCK
529:         PUSHJ   P,CNTCOM        ;MAKE SURE ALL IS OK
530: >
531:         JRST TTYCM1             ;LET COMMAND FIGURE OUT THAT COMCNT IS MAYBE NOW ZERO
532: 
533: IFN FTTTYBUG,<
534: ;WELL, WE FIXED THIS PROBLEM, I THINK. 12/1/73 
535: 
536: ;THIS AWFUL KLUDGE IS TO HELP SOLVE THE COMCNT MYSTERY
537: ;IF IT STAYS FOR MORE THAN TWO WEEKS, I SHOULD BE SHOT.  REG 10/5/73
538: CNTCOM:
539:         PUSH    P,TAC
540:         PUSH    P,TAC1
541:         CONI    PI,TAC1
542:         ANDI    TAC1,SCNOFF-1000        ;SCANNER CHANNEL ACTIVE BIT
543:         PUSH    P,TAC1
544:         CONO    PI,SCNOFF               ;TURN OFF THE SCANNER
545:         MOVEI   TAC1,0
546:         MOVSI   TAC,MTTYLN
547:         SKIPGE  TTYTAB(TAC)
548:         ADDI    TAC1,1
549:         AOBJN   TAC,.-2
550:         CAMN    TAC1,COMCNT
551:         JRST    CNTCM1
552:         PUSHACS
553:         PUSHJ   P,DISMES
554:         ASCIZ   /COMCNT & TTYTAB DISAGREE.  CALLER = /
555:         MOVE    TAC,-23(P)
556:         PUSHJ   P,DISLOC
557:         PUSHJ   P,DISMES
558:         ASCIZ   / COMCNT= /
559:         MOVE    TAC,COMCNT
560:         PUSHJ   P,DISLOC
561:         PUSHJ   P,DISTAB
562:         MOVE    TAC,TAC1-17(P)
563:         PUSHJ   P,DISLOC
564:         PUSHJ   P,DISCRLF
565:         MOVE    TAC,TTCBCK
566:         PUSHJ   P,DISOCT
567:         PUSHJ   P,DISTAB
568:         MOVE    TAC,TTCBCK+1
569:         PUSHJ   P,DISOCT
570:         PUSHJ   P,DISTAB
571:         MOVE    TAC,TTCBCK+2
572:         PUSHJ   P,DISOCT
573:         PUSHJ   P,DISCRLF
574: COMBUG:        JRST    .+3                     ;PATCH HERE TO STOP THE WORLD
575:         PUSHJ   P,DISFLUSH
576:         PUSHJ   P,DDTCALL
577:         POPACS
578:         MOVEM   TAC1,COMCNT             ;FIX IT!
579: CNTCM1: POP     P,TAC1
580:         CONO    PI,2000(TAC1)
581:         POP     P,TAC1
582:         POP     P,TAC
583:         POPJ    P,
584: 
585: ;THE 23% OVERKILL, CALL IMMED AFTER IORM OR ANDCAM OF TTYTAB
586: COMBCK:        PUSH P,IOS
587:         PUSH P,TAC
588:         MOVE TAC,-2(P)
589:         MOVE IOS,-2(TAC)        ;FETCH IORM OR ANDCAM
590:         POP P,TAC
591:         HRRI IOS,@IOS
592:         TLZ IOS,37
593:         PUSH P,IOS
594:         LDB IOS,[270400,,IOS]   ;AC FIELD
595:         SKIPN IOS
596:         SKIPA IOS,-1(P)
597:         MOVE IOS,@IOS
598:         JUMPGE IOS,[    POP P,IOS       ;NOT COM BIT
599:                         POP P,IOS
600:                         POPJ P,]
601:         POP P,IOS               ;GET INSTRUCTION BACK
602:         PUSH P,TAC
603:         PUSH P,TAC1
604:         PUSH P,AC1
605:         TLNN IOS,020000         ;IORM=436, ANDCAM=412 (SKIP IF IORM)
606:         TLZ IOS,400000          ;INDICATE ANDCAM
607:         HRRZ TAC,IOS
608:         SUBI TAC,TTYTAB         ;LINE NUMBER
609:         JUMPL   TAC,COMBCX
610:         CAIL    TAC,TTPLEN
611:         JRST    COMBCX
612:         IDIVI TAC,=36           ;TAC←INDEX INTO TTCBCK, TAC1←SHIFT CNT
613:         MOVEI AC1,1
614:         LSH AC1,(TAC1)
615:         SKIPL IOS
616:         ANDCAM AC1,TTCBCK(TAC)
617:         SKIPGE IOS
618:         IORM AC1,TTCBCK(TAC)
619: COMBCY: POP P,AC1
620:         POP P,TAC1
621:         POP P,TAC
622:         POP P,IOS
623:         POPJ P,
624: COMBCX: PUSHACS
625:         PUSHJ   P,DISMES
626:         ASCIZ   /AT COMBCK WITH INVALID INDEX = /
627:         MOVE    TAC,TAC-17(P)
628:         PUSHJ   P,DISLOC
629:         PUSHJ   P,DISCRLF
630:         JRST    COMBCY
631: >;END FTTTYBUG
    TTYSER page# 0010 next  prev
633: ;TTYATI, TTYSUB
634: ;ROUTINE TO ATTACH TTY TO A JOB
635: ;CALL:  MOVE DDB,ADDRESS OF TTY DEVICE DATA BLOCK
636: ;       MOVE ITEM,JOB NUMBER
637: ;       PUSHJ P,TTYATT
638: ;       OK RETURN       ;DDB, DAT AND TRANSLATOR TABLE SET
639: 
640: ;CALLED FROM COMCON (ATTACH) AND COMCSS (JOBINI).
641: ;ON OK RETURN   1)SETS TTYATC
642: ;               3)PUTS ADDRESS OF ATTACHED DDB INTO DDB.
643: ;               4)SETS PHYSICAL NAME TO SIXBIT /TTY LINE #/
644: ;                 OR SIXBIT /CTY/,
645: ;               5)SETS DEVOPR IF IT IS NON-ZERO.
646: 
647: 
648: IFE FTATTACH,<
649: TTYATT:
650:         >
651: ;COME HERE TO ATTACH TTY IN DDB TO JOB IN ITEM.
652: TTYATI:
653:         PUSHJ   P,STLNAC                ;SETUP LINE
654:         MOVEM   LINE,JBTLIN(ITEM)       ;SET LINE # FOR JOB
655:         DPB     ITEM,PJOBN              ;SET JOB NUMBER OF OWNER
656:         MOVSI   TAC,TTYATC              ;MAKE IT ATTACHED TO JOB
657:         IORM    TAC,DEVMOD(DDB)
658:         MOVSI   IOS,TTYDTC              ;MAKE DDB ATTACHED TO TTY
659:         ANDCAB  IOS,DEVIOS(DDB)
660:         POPJ    P,
661: 
662: ;CLOCK LEVEL (CONSOLE) "TTY" COMMAND
663: TTYSUB:HRRZS (P)                       ;USE STACK AS FLAG
664: TTYSB1: PUSHJ P,CTEXT1                  ;READ TTY COMMAND
665:         JUMPE TAC1,[CAIE TEM,"-"        ;ALLOW - ALSO
666:                 JRST NOTENF             ;NOPE
667:                 PUSHJ P,GETLCCHR        ;YES, GOBBLE TO NEXT CHAR SO WE DON'T LOOP
668:                 HRROS (P)               ;FLAG -
669:                 JRST TTYSB1]
670:         CAMN TAC1,['NO    ']
671:         JRST [  HRROS (P)               ;FLAG 'NO' SEEN
672:                 JRST TTYSB1]            ;NOTE THAT REPEATED 'NO' IS OK, BUT DOESN'T COMPLEMENT
673:         MOVSI TAC,-TCOMLN
674: TCOMLP: CAMLE TAC1,TCOMND(TAC)
675:         AOBJN TAC,.-1
676:         JUMPGE TAC,COMERA               ;ERROR, COMMAND NOT FOUND
677:         CAMN TAC1,TCOMND(TAC)
678:         JRST TCMGOT
679:         MOVE AC2,TAC1
680:         SKIPA AC1,[770000,,0]
681: TCMMSK: ASH AC1,-6
682:         ANDCM AC2,AC1
683:         JUMPN AC2,TCMMSK
684:         MOVE AC2,TCOMND(TAC)
685:         AND AC2,AC1
686:         CAME AC2,TAC1                   ;PARTIAL MATCH ON CURRENT WORD?
687:         JRST COMERA                     ;NO
688:         HLRE AC2,TAC
689:         AOJE AC2,TCMGOT                 ;ONLY COMMAND LEFT?
690:         AND AC1,TCOMND+1(TAC)
691:         CAMN AC1,TAC1
692:         JRST COMERA                     ;TOO MANY MATCHES
693: TCMGOT: PUSHJ P,STLNAC
694:         JRST @TCOMDS(TAC)
    TTYSER page# 0011 next  prev
696: ;TTYSUB TABLES
697: ;"TTY" COMMANDS, MUST BE IN ALPHABETICAL ORDER
698: DEFINE TNAMES
699: <
700:         .TMAC   ECHO,TTECHO
701:         .TMAC   FILL,FILTTY
702:         .TMAC   FULL,TTFULL
703:         .TMAC   TABS,TTTAB
704:         .TMAC   TIME,TTYTIM
705:         .TMAC   UPDATE,TTYUPD
706:         .TMAC   WHO,TTYWHO
707: >
708: 
709: DEFINE .TMAC(A,B)
710: <       SIXBIT/A/
711: >
712: 
713: XLIST
714: TCOMND: TNAMES
715: TCOMLN←←.-TCOMND
716: LIST
717: 
718: DEFINE .TMAC(A,B)
719: <       B
720: >
721: 
722: XLIST
723: TCOMDS: TNAMES
724: LIST
    TTYSER page# 0012 next  prev
726: ;FILL, ECHO, FULL, TABS, TIME, WHO
727: FILTTY: TLNE LINE,DISLIN!DDDLIN         ;THESE GUYS MAY SCREW UP
728:         POPJ P,
729:         SKIPGE (P)                      ;'NO' TYPED?
730:         TLZA LINE,TTYFIL                ;YES, DO NOFILL
731:         TLO LINE,TTYFIL                 ;FILL CR'S
732: STOLIN: HLLM LINE,LINTAB(LINE)
733:         POPJ P,
734: 
735: TTECHO: SKIPGE (P)                      ;'NO' TYPED?
736:         TLOA LINE,FULTWX                ;YES, SET AS FULL DUPLEX
737:         TLZ LINE,FULTWX                 ;CLEAR FULL DUPLEX
738:         JRST STOLIN
739: 
740: TTFULL: SKIPGE (P)
741:         TLZA LINE,FCS
742:         TLO LINE,FCS
743:         JRST STOLIN
744: 
745: TTTAB:  SKIPGE (P)
746:         TLOA LINE,TBXPND                ;EXPAND
747:         TLZ LINE,TBXPND                 ;DON'T EXPAND
748:         JRST STOLIN
749: 
750: TTYUPD: JUMPE   J,CPOPJ                 ;IF NO JOB, NO XTIME
751:         MOVSI   TAC,400000              ;THIS IS THE NO-UPDATE BIT IN XTIME
752:         SKIPGE  TAC1,(P)                ;'NO' TYPED?
753:         ORM     TAC,XTIME(J)            ;YES.  SET NO-UPDATE BIT.
754:         JUMPL   TAC1,.+2                ;'NO' TYPED?
755:         ANDCAM  TAC,XTIME(J)            ;NO.  CLEAR NO-UPDATE BIT.
756:         POPJ    P,
757: 
758: TTYTIM: JUMPE   J,CPOPJ                 ;NO JOB, NO XTIME
759:         MOVSI   TAC,400000              ;THE NO-UPDATE BIT IN XTIME
760:         SKIPL   TAC1,(P)                ;'NO' TYPED?
761:         ADD     TAC,TTIME(J)            ;NO.  UPDATE XTIME AND SET NO-UPDATE BIT
762:         MOVEM   TAC,XTIME(J)            ;IF 'NO' TYPED, CLEAR XTIME AND SET NO-UPDATE.
763:         HRRZS   DSKOPS(J)               ;MAKE ALL DISK OPERATIONS "RECENT"
764:         SETZ    TAC,                    ;ASSUME NO WAIT TIME
765:         JUMPL   TAC1,TTYTI1             ;'NO' TYPED?
766:         HRLS    DSKOPS(J)               ;NO.  MAKE NO DISK OPS RECENT
767:         SKIPGE  TAC,JBTWAT(J)           ;GET WAIT TIME
768:         ADD     TAC,UPTIME              ;MAKE IT HONEST
769: TTYTI1: MOVEM   TAC,JB2WAT(J)           ;SAVE CURRENT WAIT TIME
770:         POPJ    P,
771: 
772: TTYWHO: SKIPL   (P)                     ;'NO' TYPED?
773:         JRST    UWHO                    ;NO NO.
774: TTWHSY: MOVEI   AC3,COMWHO+2            ;TYPE OUT SYSTEM WHO LINE
775:         JRST    UWHO1
776: 
777: UWHO:   PUSHJ   P,DECIN
778:         SKIPA   TAC1,J                  ;NO ARG, USE OUR JOB #
779:         JRST    COMERA                  ;LOSE
780:         JUMPE   TAC1,TTWHSY             ;0 ARG, OR NO ARG & NOT LOGGED IN
781:         CAIL    TAC1,JOBN               ;TOO BIG?
782:         JRST    NOTLOG                  ;YES
783:         MOVE    TAC,JBTSTS(TAC1)
784:         TLNN    TAC,JNA                 ;IS IT A JOB?
785:         JRST    NOTLOG                  ;NO
786:         PUSH    P,J                     ;SAVE J
787:         PUSH    P,DDB                   ;AND DDB ON STACK
788:         MOVE    J,TAC1
789:         MOVEI   AC1,TITLE               ;USE WHO LINE MODEL
790:         SETZ    DDB,                    ;FLAG THAT IT IS TTY CALLING
791:         PUSHJ   P,WHOLIN
792:         POP     P,DDB                   ;RESTORE DDB
793:         POP     P,J                     ;AND J
794:         MOVEI   AC3,WTTYS               ;START HERE
795: UWHO1:  SKIPN   AC2,(AC3)               ;PICKUP WORD AND CHECK FOR END
796:         POPJ    P,                      ;DONE
797:         TRZN    AC2,1                   ;TEXT WORD?
798:         AOJA    AC3,UWHO1               ;NO
799:         MOVE    AC1,[POINT 7,AC2]       ;YES, MAKE BYTE POINTER
800: UWHO2:  TLNN    AC1,760000
801:         AOJA    AC3,UWHO1
802:         ILDB    TEM,AC1                 ;UNPACK THE CHARACTERS
803:         JUMPE   TEM,UWHO2
804:         PUSH    P,AC1
805:         PUSH    P,AC2
806:         PUSH    P,AC3
807:         XCT     TYO                     ;OUTPUT THE CHAR.
808:         POP     P,AC3
809:         POP     P,AC2
810:         POP     P,AC1
811:         JRST    UWHO2
812: 
813: WHOUUO:XCTR XR,[HRRZ UUO,(UCHN)]       ;POINTER TO WHERE USER WANTS STRING
814:         HRLI UUO,(<POINT 7,0>)          ;MAKE IT BYTE POINTER
815:         MOVEI AC3,COMWHO+2              ;SKIP SOME SPACES
816:         XCTR XR,[HLRE TAC,(UCHN)]       ;GET JOB NUMBER FIELD
817:         JUMPL TAC,WHOUU1                ;IF -, JUST REPORT SYSTEM WHO LINE
818:         JUMPE TAC,.+2
819:         CAIL TAC,JOBN
820:         MOVE TAC,J                      ;ZERO OR >JOBN IS US
821:         MOVE TAC1,JBTSTS(J)
822:         TLNN TAC1,JNA                   ;JOB THERE?
823:         JRST WHOUU2                     ;NO, ZERO STRING
824:         PUSH P,J
825:         MOVE J,TAC
826:         MOVEI AC1,TITLE                 ;USE PROTOTYPE
827:         SETZ DDB,                       ;FLAG WHOSER NO TTY HERE
828:         PUSHJ P,WHOLIN
829:         POP P,J
830:         MOVEI AC3,WTTYS                 ;WHERE TO PICKUP STRING FROM
831: WHOUU1: SKIPN AC2,(AC3)
832:         JRST WHOUU2                     ;FINISH OUT WORD WITH NULLS
833:         TRZN AC2,1                      ;TEXT WORD?
834:         AOJA AC3,WHOUU1                 ;NO, CHECK NEXT WORD
835:         MOVE AC1,[POINT 7,AC2]
836: WHOUU0: TLNN AC1,760000
837:         AOJA AC3,WHOUU1
838:         ILDB TEM,AC1
839:         JUMPE TEM,WHOUU0
840:         XCTR XLB,[IDPB TEM,UUO]
841:         JRST WHOUU0
842: 
843: WHOUU2: SETZ TEM,                       ;MAKE IT ASCIZ STRING
844: WHOUU3: XCTR XLB,[IDPB TEM,UUO]
845:         TLNE UUO,760000
846:         JRST WHOUU3
847:         POPJ P,
    TTYSER page# 0013 next  prev
849: ;TTYATT
850: ;COME HERE TO ATTACH TTY TO DDB THAT JOB IS ALREADY ATTACHED TO
851: ;AND FLUSH OLD DDB IF NECESSARY.
852: IFN FTATTACH,<
853: TTYATT:
854:         PUSHJ   P,STLNAC                ; GET LINE CHARACTERISTICS
855:         MOVEI   DDB,TTYLST              ;SEARCH FOR DDB THAT IS ATTACHED
856:         JRST    .+2
857: TTYAT2: HLRZ    DDB,DEVSER(DDB)
858:         JUMPE   DDB,CPOPJ               ;HAVE ALL TTY DDB'S BEEN LOOKED AT?
859:         LDB     TAC,PJOBN               ;NO, GET JOB NUMBER.
860:         HLL     TAC,DEVMOD(DDB)         ;ATTACH AND USE BITS
861:         TLNN    TAC,DVTTY               ;IS THIS STILL A TTY DDB?
862:         JRST    TTYAT2                  ;NO, THIS MUST BE IJOB.
863:         MOVE    IOS,DEVIOS(DDB)
864:         CAIN    ITEM,(TAC)              ;JOB NUMBER THE ONE TO ATTACH?
865:         TLNN    TAC,TTYATC              ;YES, IS DDB ATTACHED TO JOB?
866:         JRST    TTYAT2                  ;NO, KEEP LOOKING.
867:         TLNN    IOS,TTYDTC              ;IS DDB DETACHED FROM LINE?
868:         POPJ    P,                      ;NO, ERROR RETURN WITH DDB SET
869:         PUSH    P,DDB                   ;SAVE NEW DDB ADDRESS.
870:         MOVE    DDB,TTYTAB(LINE)        ;ZAP, CHANGE LINES
871:         LDB     TAC,PJOBN               ;GET JOB # OF OLD DDB
872:         JUMPN   TAC,TTYAT3              ;IF IT'S ZERO
873:         MOVSI   TAC,IO!TOIP             ;THEN CLEAR THESE BITS
874:         ANDCAM  TAC,DEVIOS(DDB)         ;SO DDB GETS KILLED BY TTYDET
875: TTYAT3: PUSHJ   P,TTYDET                ;DO YO STUFF
876:         POP     P,DDB                   ;GET BACK NEW GUY
877:         MOVEM   DDB,TTYTAB(LINE)        ;TTYDET CLOBBERS THIS.
878: IFN FTTTYBUG,<  PUSHJ   P,CNTCOM        >;MAKE SURE THAT ALL IS WELL?
879:         DPB     LINE,PUNIT              ;SET THIS LINE IN DDB
880:         PUSHJ   P,TTYATI                ;SET UP NEW DDB
881:                                 ;NOW, GO TO INTERUPT LEVEL TO SET DAT
882:                                 ;AND CHECK IF TYPING NEEDS TO BE STARTED.
883:         PUSH    P,ITEM                  ;SAVE THIS
884:         PUSHJ   P,XMTIN1                ;START TYPING
885:         POP     P,ITEM
886:         SETZ    TAC,
887:         JRST    SCNIN
888: >;FTATTACH
    TTYSER page# 0014 next  prev
890: ;TTYDET, TRESCN, TRESCU
891: IFN FTATTACH,<
892: ;ROUTINE TO DETACH TTY FROM JOB
893: ;CALL:  MOVE DDB,ADDRESS OF TTY DDB TO BE DETACHED
894: ;       PUSHJ P,TTYDET
895: 
896: ;CALLED FROM TTYATT AND COMCON (DETACH).
897: ;CLEARS TTYATC AND TRANSLATOR TABLE ENTRY.
898: ;SETS TTYDTC IN DEVIOS(DDB)
899: 
900: 
901: TTYDET:LDB     TAC,PJOBN       ;GET JOB NO.
902:         SETOM   JBTLIN(TAC)     ;FLAG LINE AS DETACHED.
903:         MOVSI   IOS,TTYDTC
904:         MOVE    TAC,DEVMOD(DDB)         ;SET TTY DETACHED BIT
905:         TLNE    TAC,TTYATC              ;WAS TTY ALREADY DETACHED?
906:         TDNE    IOS,DEVIOS(DDB)
907:         JRST    TTYKIL                  ;YES, MAKE TTY AVAIL. EXTRA DETACH COMMAND
908:         IORB    IOS,DEVIOS(DDB)
909:         CONO    PI,SCNOFF
910:         PUSHJ   P,TTYSKL
911:         CONO    PI,SCNON
912:         JRST    TTYKL1                  ;GO CLEAR TRANSLATOR TABLE
913: >
914: 
915: ; ROUTINE TO RESET COUNTS AND BYTE POINTERS TO RESCAN THE LAST COMMAND LINE
916: 
917: TRESCN:
918:         LDB     TAC,PCOMIC              ; GET OLD TITCTR
919: TRESC2:                                 ;HERE TO SCAN BACK TO CURRENT INPUT.
920:         MOVEM   TAC,TITCTR(DDB)         ;RESTORE IT
921:         PUSHJ   P,TBYTEP
922:         MOVEM   TAC,TITAKR(DDB)
923: TRESC1: MOVE    TAC,TIPCTR(DDB)         ;CALLED HERE FROM ↑U CODE
924:         CONO    PI,SCNOFF
925:         SUB     TAC,TITCTR(DDB)         ; THIS IS NOW THE NEW CHR. COUNT TO END OF BUFFER
926:         SKIPG   TAC
927:         ADDI    TAC,TTICHR
928:         MOVEM   TAC,TIFCTR(DDB)
929:         CONO    PI,SCNON
930:         JRST    STLNAC
931: 
932: ; ROUTINE TO RESCAN ALL COMMAND LINES IN BUFFER. CALLS TRESCN, THEN
933: ; COUNTS NUMBER OF COMMAND LINES IN BUFFER, THEN CALLS TRESCN AGAIN
934: 
935: TRESCU:TLNE IOS,TPMON                  ;MONITOR MODE?
936:         POPJ P,                         ;OH WELL, LOSERS LOSE
937:         TRNN UUO,-1
938:         JRST TRESCA
939:         LDB TAC,PCOMIC
940:         SUB TAC,TITCTR(DDB)
941:         SKIPG TAC
942:         ADDI TAC,TTICHR
943:         XCTR    XW,[MOVEM TAC,(UUO)]
944: TRESCA: PUSHJ   P,TRESCN                ;RESCAN LINE
945:         JRST    SYNCHK                  ;RE-CALCULATE ACTIVATED CHAR. COUNT.
    TTYSER page# 0015 next  prev
947: ;TBYTEP
948: ; ROUTINE TO MAKE A POINTER TO THE BUFFER OUT OF A COUNT OF CHARACTERS
949: ; FROM THE START OF THE BUFFER.
950: 
951:         XWD     441100,0
952: TLHBYT: XWD     331100,0
953:         XWD     221100,0
954:         XWD     111100,0
955:         XWD     001100,0
956: 
957: TBYTEP: PUSH    P,LINE          ;SAVE LINE
958:         MOVNS   TAC
959:         ADDI    TAC,TTICHR
960:         IDIVI   TAC,4
961:         ADD     TAC,TTIBUF(DDB)
962:         HLL     TAC,TLHBYT(LINE)
963:         POP     P,LINE          ;RESTORE LINE
964:         AOJA TAC,CPOPJ
    TTYSER page# 0016 next  prev
966: ;TTYGET, TTYFNU, TTYFND, TTYFUW, TTYERP, TTYERR
967: ;ROUTINE TO FIND TTY FOR A JOB
968: ;CALL:  MOVE ITEM,JOB NUMBER
969: ;       PUSHJ P, TTYFND
970: ;       RETURN WITH DDB SET TO ADR OF DDB
971: ;       AND DAT SET TO BYTE POINTER TO MONITOR OUTPUT BUFFER
972: 
973: TTYGET:         
974: 
975: TTYFNU:
976:         MOVE    ITEM,JOB(PID)
977: TTYFND:
978:         PUSHJ   P,TTYSRC
979: TTYDAT: MOVEI   DAT,TTOBUF(DDB)
980:         POPJ    P,
981: 
982: 
983: ;PUT JOB IN IO WAIT IF TTY BUFFER NOT EMPTY
984: ;CALLED BY NON ERROR MESSAGE ROUTINES AT UUO LEVEL
985: 
986: TTYFUW:
987:         JUMPE PID,TTYFU1
988:         PUSHACS
989:         CONSO APR,MAOFF
990:         JRST TTYFU2
991:         PUSHJ P,DISMES
992:         ASCIZ /ππPID CLOBBERED AT TTYFUW
993: /
994:         POPACS
995:         SETZ PID,
996:         JRST TTYFU1
997: TTYFU2: PUSHJ P,DISMES
998:         ASCIZ /ππPDP-6 AT TTYFUW
999: /
1000:         POPACS
1001:         POPJ P,
1002: 
1003: TTYFU1: PUSHJ   P,TTYFNU
1004:         LDB     TAC,PJOBN       ; GET JOB # OF DDB
1005:         CAME    TAC,JOB         ; IS THIS OURS?
1006:         POPJ    P,              ; NO, FORGET IT.
1007:         MOVE    TAC,TOPUTR(DDB)
1008:         CAMN    TAC,TOTAKR(DDB)
1009:         POPJ    P,
1010:         MOVEI   IOS,IOACT                       ;YES
1011:         IORB    IOS,DEVIOS(DDB)
1012:         JRST    WSYNC
1013: 
1014: ;ROUTINE TO INDICATE MONITOR ERROR MESSAGE TO BE FORCED OUT
1015: ;WHEN NO MORE ROOM IN TTO BUFFER, TTI BUFFER WILL BE USED
1016: 
1017: TTYERP:                ;ENTER HERE TO START ERROR TYPEOUT AND CLEAR INPUT
1018:         PUSHJ   P,TTYERR
1019:         JRST    SETBFI
1020: TTYERR:                                ;COME HERE IF YOU NEED SPACE BUT
1021:                                         ;DON'T NECESSARILY NEED TO FLUSH INPUT
1022:         PUSHJ   P,TTYSRC                ; FIND TTY DDB
1023:         MOVEI   IOS,MERTPO              ;SET MONITOR ERROR PRINT OUT BIT
1024:         IORB    IOS,DEVIOS(DDB)
1025:         TLNE    IOS,TTYDTC              ; LEAVE IF DETACHED LINE
1026:         POPJ    P,
1027:         PUSHJ   P,STLNAC
1028:         TLNN    LINE,DISLIN!DDDLIN
1029:         POPJ    P,
1030:         PUSHACS
1031:         HRRZ    DDB,LETAB-DPYL0(LINE)   ;GET THE RIGHT SIDE ONLY
1032:         JUMPE   DDB,TTYDX1              ;NO LINE.
1033:         HLRZ    DAT,PPCALL(DDB)
1034:         TLNE    LINE,DDDLIN             ;SKIP IF THIS IS III
1035:         TLO     DDB,400000              ;SET BIT IF DD
1036:         HLL     DAT,DDB
1037:         PUSHJ   P,PPCLR
1038: TTYDX1: POPACS
1039:         POPJ P,
    TTYSER page# 0017 next  prev
1041: ;TTYSET, TTYSTC
1042: ;ROUTINE TO SET TTY INTO USER MODE NOW.
1043: ;CALL:  MOVE DDB,ADDRESS OF DEVICE DATA BLOCK
1044: ;       PUSHJ P,TTYSET
1045: 
1046: ;CALLED FROM RUNCSS (START1)
1047: ;CLEARS DDTM,IOSUPR,USRB,TTYIOW AND IOW
1048: 
1049: 
1050: TTYSET:
1051:         MOVE    IOS,[XWD DDTM+USRB+TTYIOW+IOW,IOSUPR]
1052:         ANDCAB  IOS,DEVIOS(DDB)
1053:         POPJ    P,0
1054: 
1055: ;ROUTINE TO START TTY OUTPUT AFTER CLEARING USRB
1056: 
1057: TTYSTC:
1058:         MOVSI   TAC,USRB                ; CLEAR BIT IN MEMORY
1059:         ANDCAM  TAC,DEVIOS(DDB)
1060:         JRST    TTYSTR
    TTYSER page# 0018 next  prev
1062: ;TTYSTR, TTYUSR
1063: ;ROUTINE TO START TTY OUTPUT
1064: ;CALL:  MOVE DAT,BYTE POINTER TO LAST OUTPUT ITEM
1065: ;       MOVE DDB,ADDRESS OF TTY DDB
1066: ;       MOVE ITEM,JOB NUMBER            ;(MUST BE PRESERVED)
1067: ;       PUSHJ P,TTYSTR
1068: 
1069: ;CALLED FROM COMINI
1070: ;INITIALIZED TTY FOR MONITOR OUTPUT AND STARTS OUTPUT
1071: 
1072: TTYSTR:
1073:         MOVE    IOS,[XWD DDTM!IOBEG!IO!TPMON,IOSUPR!IOBKTL!IOACT]
1074:         ANDCAB  IOS,DEVIOS(DDB)
1075:         TLNE    IOS,TTYDTC              ;DON'T START DETACHED LINES
1076:         POPJ    P,
1077:         PUSHJ   P,STLNAC                ;GET LINE CHARACTERISTICS
1078:         MOVSI   TAC,IO!TPMON
1079:         TLNE    IOS,USRB                ;GOING OUT OF MONITOR MODE?
1080:         TLZ     TAC,TPMON               ;YES, DON'T DIDLE THESE
1081:         IORM    TAC,DEVIOS(DDB)
1082:         MOVSI   TAC,USRB+TPMON
1083:         TLNE    IOS,USRB
1084:         ANDCAM  TAC,DEVIOS(DDB)
1085:         MOVE    IOS,DEVIOS(DDB)         ;GET CORRECT IOS
1086:         SKIPLE  TISYNC(DDB)             ;ANY TYPE AHEAD?
1087:         PUSHJ   P,COMSET                ;YES.
1088:         JRST    UTYPET                  ;GO TYPE FIRST CHAR.
1089: 
1090: ;ROUTINES TO SET SCANNER TO START UP JOB WHEN OUTPUT FINISHES
1091: ;CALL:  MOVE DDB,TTY DDB ADR.
1092: ;       PUSHJ P,TTYUSR
1093: ;       TTY WILL GO TO USER MODE WHEN TYPING OUT STOPS
1094: 
1095: TTYUSR:
1096:         MOVSI   IOS,USRB                ; SET BIT TO SWITCH TTY TO USER MODE
1097:         IORM    IOS,DEVIOS(DDB)         ; WHEN MONITOR OUTPUT FINISHES
1098:         JRST    SETRUN                  ;GO FLAG JOB AS RUNABLE IMMEDIATELY
    TTYSER page# 0019 next  prev
1100: ;TTYTLK
1101: ;ROUTINE TO ADD TTY TO TALK RING
1102: ;CALL:  ADR. OF DDB TO BE ADDED TO RING AT -3(P)
1103: ;       MOVE TAC,SIXBIT /TTYN/
1104: ;       PUSHJ P,TTYTLK
1105: ;       TTY IS BUSY RETURN OR NOT A TTY OR TOO BIG A LINE NO.
1106: ;       OK RETURN, TTY ADDED TO TALK RING
1107: 
1108: IFN FTTALK,<
1109: 
1110: TTYTLK:
1111:         PUSHJ   P,GETDDB                ; IN CASE NOT SET UP
1112:         POPJ    P,                      ;NONE AVAIL. GIVE UP
1113: IFN FTTKBG,<
1114:         LDB     CHR,PUNIT               ;BH 3/15/74 FOR BUG TRAP BELOW
1115: >;FTTKBG
1116:         MOVE    TAC,DEVMOD(DDB)
1117:         TLNN    TAC,DVTTY
1118:         POPJ    P,
1119:         MOVE    IOS,DEVIOS(DDB) ;IS TTY IN MONITOR MODE AND LEFT HAND MARGIN?
1120:         TLNE    IOS,TTYHLD      ;EVIL THINGS MIGHT HAPPEN IF WE TRY TALKING
1121:         POPJ    P,              ;TO A LINE THAT'S HOLDING.
1122:         MOVE    LINE,-3(P)              ;TTY GIVING TALK COMMAND
1123:         MOVE    LINE,DEVNAM(LINE)       ;ITS NAME
1124:         MOVE    TAC,DEVNAM(DDB) ;OPR IS NEVER TOO BUSY...
1125:         CAMN    LINE,TAC                ;IF THE SAME,
1126:         POPJ    P,                      ;  NO SOAP
1127:         CAME    LINE,DEVOPR             ;EITHER ONE OPR?
1128:         CAMN    TAC,DEVOPR
1129:         JRST    TTYTK1
1130:         MOVSI   TAC,TLKPRV
1131:         TDNE    TAC,JBTPRV(J)   ;CHECK PRIVILEGE
1132:         JUMPN   J,TTYTK1        ;JUMP IF PRIV SET
1133:         TLNE    IOS,TPMON
1134:         TLNN    IOS,IOFST
1135:         POPJ    P,                      ;NO, HE IS BUSY.
1136: TTYTK1: CONO    PI,SCNOFF
1137: IFN FTTKBG,<
1138:         HRRZ    TAC,TTYTAB(CHR)         ;BH 3/15/74
1139:         JUMPE   TAC,TTYTK2              ;  BUG TRAP: MAYBE NO OBJECT DDB HERE?
1140: >;FTTKBG
1141:         LDB     LINE,PUNIT              ;LINE NUMBER IN RING.
1142:         MOVSI   TAC,TLKRNG
1143:         LDB     CHR,PTALK
1144:         TDNN    TAC,LINTAB(LINE)
1145:         HRRZ    CHR,LINE
1146:         IORM    TAC,LINTAB(LINE)
1147:         EXCH    DDB,-3(P)               ;GET DDB OF TALKER
1148:         LDB     LINE,PUNIT              ;LINE NO. OF TALKER
1149:         DPB     CHR,PTALK               ;SET TO POINT INTO RING
1150:         MOVSI   TAC,TLKRNG
1151:         IORM    TAC,LINTAB(LINE)
1152:         MOVEM   LINE,TAC                ;SAVE LINE NO. OF TALKER
1153:         EXCH    DDB,-3(P)               ;RESTORE
1154:         LDB     LINE,PUNIT              ;LINE NO. IN RING AGAIN
1155:         DPB     TAC,PTALK               ;MAOE IT POINT TO TALKER
1156:         CONO    PI,SCNON
1157:         JRST    CPOPJ1                  ;OK RETURN
1158: 
1159: IFN FTTKBG,<
1160: TTYTK2: MOVE    TAC,-3(P)               ;BH 3/15/74 BUG TRAP HERE TO PAGE END
1161:         PUSHACS
1162:         PUSH    P,DDB                   ;FORMER DDB OF TALKEE
1163:         PUSH    P,CHR                   ;DEAD TALKEE
1164:         PUSH    P,TAC                   ;TALKER'S DDB
1165:         MOVE    DDB,TAC
1166:         LDB     TAC,PUNIT               ;TALKER
1167:         PUSH    P,TAC
1168:         PUSHJ   P,DISMES
1169:         ASCIZ /ππππNO DDB FOR TALKEE AT TTYTK1!!
1170: TALKER=/
1171:         POP     P,TAC
1172:         PUSHJ   P,DISOCT
1173:         PUSHJ   P,DISMES
1174:         ASCIZ /  DDB=/
1175:         POP     P,TAC
1176:         PUSHJ   P,DISOCT
1177:         PUSHJ   P,DISMES
1178:         ASCIZ /
1179: TALKEE=/
1180:         POP     P,TAC
1181:         PUSHJ   P,DISOCT
1182:         PUSHJ   P,DISMES
1183:         ASCIZ /  DDB WAS AT /
1184:         POP     P,TAC
1185:         PUSHJ   P,DISOCT
1186:         PUSHJ   P,DISMES
1187:         ASCIZ /
1188: FIND A WIZARD!  IF NONE, TYPE: POPJ 3,$X
1189: /
1190:         PUSHJ   P,DISFLU
1191:         POPACS
1192:         PUSHJ   P,DDTCAL
1193:         CONO    PI,SCNON
1194:         POPJ    P,
1195: >;FTTKBG
1196: >
    TTYSER page# 0020 next  prev
1198: ;TTYSRC, STLNAC
1199: ;ROUTINE TO SEARCH TRANSLATOR TABLE FOR TTY
1200: ;CALL:  MOVE J,JOB NUMBER
1201: ;       PUSHJ P,TTYSRC
1202: ;       RETURN WITH ADDRESS OF DEVICE DATA BLOCK IN DDB.
1203: 
1204: 
1205: ↑↑TTYSRC:
1206:         JUMPE   J,TTYF1                 ;SEARCH FOR OPER. TTY IF JOB NO. 0
1207:         MOVSI   LINE,TTYATC
1208:         MOVEI   DDB,TTYLST              ;TTYDDBS START HERE
1209: TTYSRA: LDB     TAC,PJOBN               ;JOB ATTACHED TO THIS DDB
1210:         CAIE    TAC,(J)                 ;IS THIS THE ONE
1211:         JRST    TTYF0
1212:         TDNE    LINE,DEVMOD(DDB)        ;IS HE ATTACHED TO IT?
1213:         JRST    TTYF9                   ;YES.
1214: TTYF0:  HLRZ    DDB,DEVSER(DDB)         ;FOLLOW CHAIN
1215:         JUMPN DDB,TTYSRA                ;TO ITS END
1216: TTYF1:  SKIPE TAC,DEVOPR
1217:         JRST TTYF3
1218:         MOVEI   LINE,TCONLN             ;NO USE CTY.
1219:         SKIPE   DDB,TTYTAB(LINE)        ;DOES IT HAVE A DDB?
1220:         JRST    TTYF9
1221:         MOVSI   TAC,'CTY'               ;NO
1222: TTYF3:  PUSHJ   P,GETDDB                ;GET A DDB FOR DEVOPR
1223:         JRST    SCREW                   ;OH BOY HERE WE GO
1224: TTYF9:  MOVE    IOS,DEVIOS(DDB)         ;SET UP IOS
1225: 
1226:         SETZ    LINE,
1227:         TLNE    IOS,TTYDTC
1228:         POPJ    P,
1229: STLNAC:
1230:         LDB     LINE,PUNIT              ; GET UNIT # FROM DDB
1231:         HLL     LINE,LINTAB(LINE)               ;AND LINE BITS
1232:         POPJ    P,0                     ;RETURN
1233: 
1234: SCREW:  PUSHACS
1235:         PUSHJ P,DISDATE
1236:         PUSHJ P,DISMES
1237:         ASCIZ/LOSE BIG! SOMEONE IS TRY TO TYPE ON A VIRGIN TTY,
1238: AND NO CORE AVAILABLE.
1239: /]
1240:         POPACS
1241:         CONSZ PI,77400  ;WHERE ARE WE
1242:         POPJ P,         ;CROSS FINGERS AND PRAY
1243:         JSP DAT,UERROR  ;UUO LEVEL, A WAY OUT.
    TTYSER page# 0021 next  prev
1245: ;GETDDB, LOG2LN
1246: ;ROUTINE TO SETUP DDB FOR OUTPUT
1247: ;CALL   MOVE TAC,[SIXBIT /TTY#/
1248: ;       PUSHJ P,GETDDB
1249: ;       NONE AVAILABLE RETURN
1250: ;       RETURN WITH LINE AND DDB SETUP
1251: 
1252: GETDDB:
1253:         PUSHJ P,LOG2LN          ;CONVERT TO LINE NUMBER
1254:         POPJ P,                 ;ILLEGAL
1255: GETDBA: CAIL LINE,TTPLEN        ;LEGAL LINE NUMBER?
1256:         POPJ P,                 ;NO
1257: GETDB1: SKIPE DDB,TTYTAB(LINE)          ;DOES THIS LINE ALREADY HAVE A DDB?
1258:         JRST CPOPJ1                     ;YES
1259:         CAIL LINE,PTYL0
1260:         POPJ P,                 ;ONLY DDBSRC WILL CREATE PTY DDB! (BH 3/18/74)
1261:         PUSHJ P,DDBSRC          ;NO. SEARCH FOR FREE DDB
1262:         POPJ P,                 ;NONE AVAILABLE
1263:         HLLZM IOS,DEVIOS(DDB)           ;INITIALIZE STATE
1264:         PUSH P,DEVNAM(DDB)
1265:         MOVEI TAC,ASSCON+ASSPRG
1266:         ANDCAM TAC,DEVMOD(DDB)
1267:         JRST TPOPJ1
1268: 
1269: LOG2LN:MOVS TAC,TAC
1270:         MOVEI LINE,TCONLN
1271:         CAIN TAC,'CTY'
1272:         JRST CPOPJ1
1273:         TRC TAC,'TTY'
1274:         TRNE TAC,-1
1275:         POPJ P,                 ;NOT TTY#
1276: SIX2LN:JUMPE TAC,CPOPJ         ;JUST TTY
1277:         MOVEI LINE,
1278: LOG2LL: ROT TAC,3
1279:         TRZE TAC,2
1280:         TRNE TAC,5
1281:         POPJ P,                 ;NOT DIGIT
1282:         ROTC TAC,3              ;DIGIT → LINE
1283:         JUMPN TAC,LOG2LL        ;MORE?
1284:         CAIGE LINE,TTPLEN       ;NO, CHECK LEGALITY
1285:         AOS (P)
1286:         POPJ P,
    TTYSER page# 0022 next  prev
1288: ;DDBSRC, STDTBL
1289: ;ROUTINE TO SEARCH FOR FREE TTY DEV DATA BLOCK
1290: ;CALL:  MOVE LINE,TTY LINE NO.
1291: ;       PUSHJ P,DDBSRC
1292: ;       NONE FOUND OR LINE NO. TOO BIG
1293: ;       RETURN DDB,LINE AND DEVNAM SET AND BITS TPMON,IOFST,IOACT,
1294: ;               TTYUSE,ASSCON SET.
1295: ;       IF CALLED WITH LINE SET TO -1 A DETTACHED
1296: ;       DDB IS CREATED AND GIVEN TO JOB IN ITEM.
1297: 
1298: DDBSRC:
1299:         HRRE    TAC,LINE                        ; NUMBER OF LINE ONLY
1300:         CAILE   TAC,TTPLEN              ;IS LINE NO. TOO BIG
1301:         POPJ    P,                      ;YES.
1302:         HLL LINE,LINTAB(LINE)
1303:         TLNN LINE,DDDLIN
1304:         JRST DDBSR1
1305:         MOVE AC3,AVLBIT
1306:         CONSO PI,770000
1307:         TDNE AC3,VDMAP-DDL0(LINE)       ;NOT AT PI LEVEL - SEE IF COMPLETELY FREE
1308:         SKIPE DDOFF                     ;ALSO SEE IF DD UP
1309:         POPJ P,
1310: DDBSR1: MOVEI AC3,TTYFS
1311:         PUSHJ P,SFSGET
1312:         POPJ P,
1313:         MOVEI   DDB,DDBSKW(AC1)
1314:         HRLI    AC1,TTYLST-DDBSKW
1315:         BLT     AC1,TTYPTR(DDB) ;COPY PART OF A REAL DDB INTO OUR NEW BLOCK
1316:         SETZM   DEVIOS(DDB)
1317:         SETZM   DEVLOG(DDB)
1318:         SETZM   DEVNAM(DDB)
1319:         SETZM   DEVBUF(DDB)
1320:         SETZM   PTYPTR(DDB)
1321:         SETZM   SAVDDB(DDB)
1322:         MOVSI   AC1,TTICHR
1323:         DPB     AC1,PJOBN       ;CLEAR JOB NUMBER IN DEVCHR
1324:         DPB     AC1,PUNIT       ;UNIT NUMBER TOO  BH 5/6/74
1325:         HRRI    AC1,TIBF-1(DDB)
1326:         MOVEM   AC1,TTIBUF(DDB)
1327:         MOVSI   AC1,TTOCHR
1328:         HRRI    AC1,TOBF-1(DDB)
1329:         MOVEM   AC1,TTOBUF(DDB)
1330:         PUSHJ   P,TSETBF
1331:         MOVSI TAC,STDTBL
1332:         HRRI TAC,ACTBTS(DDB)
1333:         BLT TAC,ACTMOD(DDB)
1334:         MOVE    TAC,[XWD TTYUSE!TTYATC,ASSCON!ASSPRG]
1335:         ANDCAM  TAC,DEVMOD(DDB)
1336:         HRLZI   AC1,(DDB)
1337:         HRR     AC1,DEVSER(DDB)
1338:         CONO    PI,SCNOFF
1339:         EXCH    AC1,TTYLST+DEVSER
1340:         MOVEM   AC1,DEVSER(DDB)
1341:         CONO    PI,SCNON
1342:         MOVSI   TAC,PROG
1343:         MOVEM   TAC,DEVIAD(DDB)         ;CLEARS PHPOS
1344:         MOVEM   TAC,DEVOAD(DDB)         ;CLEARS PFITCH
1345:         MOVE    IOS,[XWD TPMON+IOFST,IOACT]
1346:         MOVEM   IOS,DEVIOS(DDB)         ;MAKE SURE HE LOOKS LIKE A VIRGIN.
1347:         PUSHJ   P,TSETBF                ;INITIALIZE BUFFERS
1348:         MOVE    TAC,[XWD TTYUSE,0]      ;INITIALIZE DATA BLOCK.
1349:         CAIE    LINE,-1         ;IS SOME ONE GETTING A DETTACHED DDB?
1350:         JRST [  TLNN LINE,DDDLIN!DISLIN
1351:                 JRST SCNIN              ; NO, FINISH UP AND LEAVE
1352:                 PUSHJ P,DPYMAKE         ; MAKE UP A DPY HEADER
1353:                 JRST TTYKL5             ;LOSE - RELEASE THE DDB & LEAVE
1354:                 JRST SCNIN]
1355:         TLO     TAC,TTYATC      ;ATTACH JOB TO DDB
1356:         IORM    TAC,DEVMOD(DDB)
1357:         SETOM   JBTLIN(ITEM)    ;YES, FLAG AS DETTACHED
1358:         DPB     ITEM,PJOBN      ;MAKE IT HIS;
1359:         MOVSI   IOS,TTYDTC      ;FLAG AS DETTACHED FROM LINE
1360:         IORB    IOS,DEVIOS(DDB)
1361:         JRST    CPOPJ1          ;SKIP RETURN
1362: 
1363: ;STANDARD SPECIAL ACTIVATION MODE BREAK TABLE
1364: ;BREAK ON ANYTHING BUT LETTER OR NUMBER
1365: STDTBL: 777777777777
1366:         777700037600
1367:         000000374000
1368:         000007600000
    TTYSER page# 0023 next  prev
1370: ;SCNIN
1371: ;INITIALIZE TTY DEVICE DATA BLOCK(CALLED FROM TTYATT TOO)
1372: ;CALL:  MOVE TAC,BITS IN DEVMOD TO BE TURNED ON
1373: ;       MOVE DDB,ADDRESS OF DEVICE DATA BLOCK
1374: ;       PUSHJ P,SCNIN
1375: ;       SKIP RETURN ALWAYS
1376: 
1377: ;       CALLED BY JRST FROM TTYATT
1378: ;       AND FALLS IN FROM DDBSRC ABOVE
1379: 
1380: ;SETS PHYSICAL NAME TO SIXBIT /TTY#/ OR SIXBIT /CTY/
1381: ;       WHERE # IS THE LINE NUMBER.
1382: ;STORES LINE NUMBER IN DEVICE DATA BLOCK
1383: 
1384: SCNIN:  IORM TAC,DEVMOD(DDB)
1385:         DPB LINE,PUNIT                  ;SET LINE NO. IN DDB.
1386: 
1387: IFN FTTALK,<
1388:         DPB LINE,PTALK                  ;SETUP TALK RING TO CONTAIN
1389:                                         ;ONLY THIS TTY.
1390: >
1391:         MOVEI TAC,
1392:         ANDI LINE,-1
1393: SCNIN0: ROTC TAC,-3
1394:         HRRI TAC,2
1395:         ROT TAC,-3
1396:         JUMPN LINE,SCNIN0
1397:         HRRI TAC,'TTY'
1398:         MOVSM TAC,DEVNAM(DDB)
1399:         PUSHJ   P,STLNAC
1400:         HRRM DDB,TTYTAB(LINE)   ;SET DDB ADR. IN TRANSLATOR TABLE.
1401:         MOVSI TAC,'CTY'
1402:         TLNE    LINE,CTYLIN             ;IS THIS CONSOLE TTY?
1403:         MOVEM TAC,DEVNAM(DDB)   ;YES, SET NAME TO CTY.
1404:         JRST CPOPJ1                     ;SUCCESSFUL RETURN.
    TTYSER page# 0024 next  prev
1406: ;TTYSKL, TTYREL, TTYKIL
1407: ;CALL TO MAKE REQUEST TO DPYKIL.
1408: ;CONO PI,SCNOFF MUST HAVE BEEN DONE BEFORE THIS ROUTINE IS CALLED.
1409: TTYSKL: PUSHJ   P,STLNAC                ;GET LINE CHARACTERISTICS..
1410:         TLNE    LINE,DDDLIN!DISLIN
1411:         SKIPN   AC2,LETAB-DPYL0(LINE)
1412:         POPJ    P,
1413:         MOVEI   AC1,-DPYL0(LINE)
1414:         SETO    AC3,
1415:         EXCH    AC3,LECLIN(AC2)
1416:         JUMPL   AC3,CPOPJ
1417:         SETZM   LEACT(AC2)              ; SEE IF THE LINE EDITOR SAYS ANYTHING IN THIS TIME
1418:         LSH     AC1,=12
1419:         ADD     AC1,DPYKRQ              ; MAKE IT APPROPRIATE LENGTH
1420:         CONO    PI,PIOFF
1421:         IDPB    AC1,CLOCK(PID)
1422:         CONO    PI,PION
1423:         POPJ    P,
1424: 
1425: TTYREL:
1426: IFN DILNUM,<
1427:         LDB LINE,PUNIT          ;SETUP LINE
1428:         PUSHJ P,DILTRL          ;CHECK FOR DIALER RELEASE
1429: >;DILNUM
1430:         HLLZS TAC1,DEVIOS(DDB)  ;CLEAR INITTED BITS IN IOS.
1431:         MOVE TAC,DEVMOD(DDB)
1432:         TLNE TAC,TTYATC         ;THAT'S ALL IF IT'S HIS CONSOLE
1433:         POPJ P,
1434:         MOVSI IOS,TPMON         ;NO, PUT HIM BACK IN MONITOR MODE
1435:         IORB IOS,DEVIOS(DDB)
1436:         TRNE TAC,ASSCON         ;DON'T KILL IF ASSIGNED BY CONSOLE
1437:         POPJ P,
1438: 
1439: ;ROUTINE TO SET SCNSER TO RETURN TTY TO VIRGIN STATE
1440: ;CALL:  MOVE    DDB, ADDRESS OF DEVICE DATA BLOCK
1441: ;       PUSHJ   P,TTYKIL
1442: 
1443: ;CALLED FROM COMCSS (JOBKIL).
1444: ;IF NOT OPERATOR CONSOLE, THEN
1445: ; 1)CLEAR PHYSICAL AND LOGICAL  NAMES,
1446: ; 2)CLEAR JOB NUMBER ASSIGNMENT
1447: ;       3)CLEAR TTYUSE,TTYATC,ASSCON,ASSPRG,
1448: ;       4)CLEAR ENTRY IN TRANSLATOR TABLE.
1449: 
1450: TTYKIL:
1451:         CONO    PI,SCNOFF                       ;LET'S DO IT RIGHT!
1452:         TLNE    IOS,TTYDTC
1453:         JRST    TTYKL5                  ;TAKE 3 GIANT STEPS IF YOU'RE DETACHED.
1454:         PUSHJ   P,TTYSKL                ;IF A DPY, MAKE IT AVAIL. (SETS LINE)
1455: TTYKL7: SKIPN   DDB,TTYTAB(LINE)        ;DID SOMEONE ELSE GET IT?
1456:         JRST    TYPT1                   ;YES.
1457:         TRNN    DDB,-1                  ;IS THERE REALLY ONE HERE?
1458:         JRST    [PUSHJ P,TTYKL9         ;NO DDB, NO NOTHING!
1459: IFN FTTTYBUG,<  PUSHJ P,CNTCOM          >
1460:                 JRST TYPT1]             ;AND THEY'RE OFF
1461:         MOVSI   IOS,TTYIOW!IOW!TTYDTC!DDTM      ; CLEAR TTY INPUT AND OUTPUT
1462:         ANDCAM  IOS,DEVIOS(DDB)         ;WAIT BITS SO TTY WILL BE KILLED
1463:                                         ;PROPERLY AT INTER. LEVEL IF STILL OUTPUTING
1464:         MOVE    TAC,[TTYATC,,ASSCON!ASSPRG]
1465:         ANDCAM  TAC,DEVMOD(DDB)         ;TTY IS NO LONGER A JOB'S CONSOLE.
1466:         MOVSI   IOS,TPMON               ;CLEAR JOB NUMBER
1467:         DPB     IOS,PJOBN
1468:         IORB    IOS,DEVIOS(DDB)         ;TURN TPMON ON IN CASE TTY IS
1469:                                         ;STILL OUTPUTTING
1470:         SKIPG   TTYTAB(LINE)            ;REQUEST IN ALREADY?
1471:         JRST    TYPT1                   ;LEAVE NOW!
1472:         MOVE    TAC,TITCTR(DDB)         ;TAKR COUNT
1473:         CAMN    TAC,TIPCTR(DDB)         ;COMPARE WITH PUTR
1474:         JRST    NOTYPA                  ;NO TYPE AHEAD
1475:         SKIPLE  TISYNC(DDB)             ;ANY LINES TO TELL MONITOR ABOUT?
1476:         PUSHJ   P,COMSET                ;WAKE COMMAND DECODER
1477:         JRST    TYPT1
1478: 
1479: NOTYPA:
1480:         TLNN    LINE,PTYUSE             ;DON'T KILL DDB FOR USED PTY'S.
1481:         TLOE    IOS,IO+TOIP             ;IS IT OUTPUTTING OR TALKING?
1482:         JRST    TTYKL6
1483: TTYKL5: MOVEI   TAC,TTYLST              ;DON'T KILL THIS GUY
1484:         CAIE    TAC,(DDB)               ;IS THIS THE FIRST DDB
1485:         JRST    TTYKL2                  ;BLAST THE MOTHER
1486:         HLLZS   DEVIOS(DDB)             ;CLEAR INITTED STUFF IN IOS
1487:         PUSHJ   P,LINCLR                ;CLEAR LINE TABLE.
1488:         SETZM   DEVLOG(DDB)             ;CLEAR LOGICAL NAME
1489:         JRST TYPT1                      ;ON CLYDE.
1490: 
1491: TTYKL6: IORB    IOS,DEVIOS(DDB)         ;MAKE SURE IT GETS KILLED AT INTERUPT LEVEL.
1492:         JRST    TYPT1
    TTYSER page# 0025 next  prev
1494: ;MORE TTYKIL
1495: ;THIS RETURNS A DDB TO FREE STORAGE.
1496: 
1497: TTYKL2: MOVEI   AC1,TTYLST              ;SEARCH CHAIN FOR POINTER TO DDB.
1498: TTYKL3: MOVE    TAC,AC1
1499:         HLRZ    AC1,DEVSER(AC1)         ;LINK
1500:         CAIE    AC1,(DDB)               ;IS THIS THE GUY THAT POINTS TO OURS
1501:         JUMPN   AC1,TTYKL3
1502:         JUMPE   AC1,TTYKL4
1503:         MOVE    AC1,DEVSER(DDB)
1504:         MOVEM   AC1,DEVSER(TAC)         ;LINK HIM OUT
1505: TTYKL8: PUSHJ   P,LINCLR                ;CLEAR LINTAB BITS
1506:         TLNN    IOS,TTYDTC
1507:         PUSHJ   P,TTYKL9
1508: IFN FTTTYBUG,<  PUSHJ   P,CNTCOM        >
1509:         CONO    PI,SCNON                ;AND AWAY THEY GO!!
1510:         MOVEI   AC1,-DDBSKW(DDB)
1511:         PUSHJ   P,FSGIVE
1512:         MOVEI   DDB,0
1513:         POPJ    P,
1514: 
1515: LINCLR: TLNE    IOS,TTYDTC              ;NO LINE IF DETACHED
1516:         POPJ    P,
1517:         TLNN    LINE,PTYLIN             ;PTY'S AREN'T IN THIS TABLE
1518:         IOR     LINE,LINBIT(LINE)       ;OR IN INITIALIZE BITS
1519:         TLZ     LINE,KILMSK             ;CLEAR BITS IN LINE TABLE
1520:         HLLM    LINE,LINTAB(LINE)
1521:         POPJ    P,
1522: 
1523: TTYKL1: LDB     LINE,PUNIT              ;LINE NO.
1524:         SKIPGE  TTYTAB(LINE)
1525:         SOS     COMCNT
1526:         PUSHJ   P,TTYKL9                ;CLEAR TRANSLATOR TABLE
1527: IFN FTTTYBUG,<  PUSHJ   P,CNTCOM>
1528:         SETZM   DEVNAM(DDB)
1529:         JRST    TSETBF                  ;BLAST TYPE AHEAD AND OUTPUT.
1530: 
1531: TTYKL4:
1532:         PUSHACS
1533:         PUSH P,TAC
1534:         PUSH P,DDB
1535:         PUSHJ P,DISMES
1536:         ASCIZ /πππDDB NOT FOUND IN LIST AT TTYKIL
1537: DDB=/
1538:         POP P,TAC
1539:         PUSHJ P,DISOCT
1540:         PUSHJ P,DISMES
1541:         ASCIZ /
1542: LAST LINK=/
1543:         POP P,TAC
1544:         PUSHJ P,DISOCT
1545:         PUSHJ P,DISMES
1546:         ASCIZ /
1547: /
1548:         POPACS
1549:         JRST TTYKL8             ;GIVE IT BACK ANYWAY
1550: 
1551: ;ALL THE "PUSHJ P,TTYKL9"S ABOVE USED TO BE "SETZM TTYTAB(LINE)"
1552: ;IF LH OF TTYTAB ENTRY ≠ LINE THEN WE WERE IN A TALK RING AND
1553: ;THIS ROUTINE PATCHES THE RING UP TO LEAVE US OUT
1554: 
1555: TTYKL9: LDB AC2,PTALK           ;MY TALKRING POINTER
1556:         MOVEI AC3,0
1557:         EXCH AC3,TTYTAB(LINE)   ;DON'T NEED TTYTAB ANYMORE
1558:         JUMPE AC3,CPOPJ         ;GRUMBLE, SOMEBODY CLOBBERED IT ALREADY
1559:         CAIN AC2,(LINE)         ;POINTS TO ME?
1560:         POPJ P,                 ;YES, NO PROBLEM
1561:         PUSH P,AC2              ;SAVE NEXT GUY
1562:         MOVE AC3,LINE           ;MY LINE NUMBER
1563: TTYK91: MOVE LINE,AC2           ;LOOP THROUGH TILL YOU FIND ME
1564:         LDB AC2,PTALK
1565:         CAIE AC2,(AC3)
1566:         JRST TTYK91             ;NOT ME YET
1567:         POP P,AC2               ;RETRIEVE MY POINTEE
1568:         DPB AC2,PTALK           ;MAKE PREV POINT TO NEXT
1569:         CAIE AC2,(LINE)
1570:         JRST TTYK92
1571:         MOVSI AC2,TLKRNG
1572:         ANDCAM AC2,LINTAB(LINE) ;TURN OFF THE FLAG IF ONLY ONE LEFT
1573: TTYK92: MOVE LINE,AC3           ;FIX LINE
1574:         POPJ P,
    TTYSER page# 0026 next  prev
1576: ;OUTCH6, OUTCHS, OUTCHR
1577: ;MORE CHARACTER AND BUFFER HANDLING ROUTINES
1578: 
1579: ;OUTCHR CALLED AT UUO LEVEL TO OUTPUT A CHARACTER
1580: ;DAT AND DDB MUST BE SET UP
1581: ;CHECK IS MADE FOR WHETHER SPECIAL ECHO IS REQUIRED
1582: ;RIGHT THINGS ARE DONE WITH PHPOS & HPOS(NEEDNT BE SET)
1583: ;CALL   MOVE    CHR,CHAR TO BE OUTPUT
1584: ;       PUSHJ   P,OUTCHR
1585: ;       ONLY RETURN, WITH CHAR. OR ITS SPECIAL ECHO PLACED IN OUT BUFFER
1586: 
1587: OUTCH6: ADDI CHR,40            ;TYPE OUT SIXBIT.
1588: 
1589: OUTCHS:
1590:         JUMPE PID,OUTC1S
1591:         CONSO APR,MAOFF         ;ARE WE REALLY THE TEN?
1592:         JRST CTYTYO             ;NO, JUST TYPE ON THE SIX'S CTY
1593:         PUSHACS
1594:         PUSHJ P,DISMES
1595:         ASCIZ /ππPID CLOBBERED AT OUTCHS
1596: PID=/
1597:         MOVE TAC,PID
1598:         PUSHJ P,DISOCT
1599:         PUSHJ P,DISMES
1600:         ASCIZ /
1601: /
1602:         POPACS
1603:         SETZ    PID,            ;MAKE IT RIGHT!!
1604: OUTC1S: PUSH    P,TAC
1605:         PUSH    P,HPOS  ;CALL OUTCHR ROUTINE
1606:                                 ; BUT SAVE ITEM AND TAC
1607:         PUSHJ   P,OUTCH5
1608:         POP     P,HPOS
1609:         JRST    TPOPJ
1610: 
1611: OUTCHR: MOVE    TAC,DEVIOS(DDB) ;GET IOS
1612:         TLNE    TAC,TTYDTC
1613:         POPJ P,
1614:         ANDI TAC,16
1615:         CAIN TAC,10             ;MODE 10 OR 11?
1616:         JRST    OUTCH2          ;YES, NO CONVERSION
1617:         MOVEI   AC3,20          ;CHECK FREE SPACE
1618:         CAML    AC3,TOFCTR(DDB) ; FOR EXPANDING CHARS
1619:         JRST    GETCH1          ;NOT ENOUGH ROOM
1620: OUTCH5: MOVE    TAC,DEVIOS(DDB)
1621:         TLNE TAC,TTYDTC
1622:         POPJ    P,
1623:         ANDI TAC,16
1624:         CAIN TAC,10             ;MODE 10 OR 11?
1625:         JRST OUTCH2             ;YES, NO CONVERSION
1626:         ANDI    CHR,177 ;MASK ANY JUNK
1627:         PUSH    P,LINE
1628:         PUSHJ   P,STLNAC        ;SET UP LINE
1629:         LDB     HPOS,PHPOS      ;GET HORIZONTAL POSITION
1630:         MOVE    AC3,HPOS        ;SAVE FOR TAB
1631:         PUSHJ   P,ADJHP ;NEW HPOS AFTER CHAR OUTPUT
1632:         JFCL
1633:         TLNE    LINE,DISLIN!IMLIN!DDDLIN!PTYLIN
1634:         JRST    OUTCHA          ;PAGE PRINTER WILL HANDLE CRLF
1635:         CAIL    HPOS,=72        ;DID IT GO OVER LINE?
1636:         PUSHJ   P,CRLFEC        ;YES, OUTPUT CRLF
1637: OUTCHA: DPB     HPOS,PHPOS      ;UPDATE IN CORE
1638:         TLNN    TAC,SPOUT       ;VT,FF,HT?
1639:         JRST    OUTC1X          ;NO.
1640:         TLNE    LINE,PTYLIN     ;IS THIS A PTY?
1641:         TLNE    LINE,IMPBIT     ;YES. IS IT AN IMP?
1642:         JRST    OUTCH1          ;NOT A PTY, OR AN ARPA-PTY. - EXPAND TABS, ETC.
1643: OUTC1X: POP     P,LINE
1644: OUTCH2: CONO    PI,SCNOFF       ;PREVENT REENTRANT CALLS ON PUTCHO...
1645:         PUSHJ   P,PUTCHO        ;PUT OUT THE CHAR.
1646:         CONO    PI,SCNON
1647:         POPJ    P,
    TTYSER page# 0027 next  prev
1649: ;MORE OUTCHR  ADJHP
1650: ;HERE ON UUO OUTPUT OF HT,FF,VT
1651: 
1652: OUTCH1: MOVE    HPOS,AC3        ;POS BEFORE THE TAB
1653:         MOVE    TAC,CHR         ;COPY THE CHARACTER
1654:         CAIN    CHR,11          ;IS IT A TAB
1655:         TLNE    LINE,TBXPND     ;ARE WE ALWAYS EXPANDING THEM?
1656:         JRST    OUTC1Y          ;EXPAND!
1657:         TLNE    LINE,IMLIN!PTYLIN!DISLIN!DDDLIN ;NEED IDLE CHARS.?
1658:         JRST    OUTC1X          ;NO
1659: OUTC1A: POP     P,LINE          ;HERE ON OUTPUT OF TAB TO SMART TTY
1660:         ANDI    HPOS,7          ;JUST LOW PART FOR INDEX
1661:         XCT     (HPOS)[ MOVEI HPOS,6    ;8 SPACES-2 IDLES
1662:                         MOVEI HPOS,7    ;7 SPACES-1 IDLE
1663:                         MOVEI HPOS,7    ;6 SPACES-1 IDLE
1664:                         MOVEI HPOS,7    ;5 SPACES-1 IDLE
1665:                         MOVEI HPOS,7    ;4 SPACES-1 IDLE
1666:                         JRST OUTCH2     ;3 SPACES-0 IDLES
1667:                         JRST OUTCH2     ;2 SPACES-0 IDLES
1668:                         JRST OUTC1Z]    ;1 SPACE -CONVERT TO SPACE (OR CTY WILL MISS TAB STOP)
1669:         PUSHJ   P,OUTCH2        ;SEND THE REAL CHAR
1670:         MOVEI   CHR,IDLECH      ;A DELAY CHARACTER
1671:         JRST    OUTC1C          ;OUTPUT SLUFFS. COUNT WILL BE MODIFIED ON VT,FF
1672: 
1673: OUTC1Y: POP     P,LINE          ;HERE TO EXPAND CHARACTER.
1674: OUTC1Z: MOVEI   CHR,40          ;STUPID TTY.
1675:         CAIE    TAC,11          ;H TAB?
1676:         MOVEI   CHR,12          ;NO. OUTPUT LF'S.
1677: OUTC1C: CAIN    TAC,14          ;FF?
1678:         MOVEI   HPOS,0          ;YES. 8 LF'S.
1679:         CAIN    TAC,13          ;VT?
1680:         MOVEI   HPOS,4          ;YES. 4 LF'S.
1681: OUTC1B:
1682:         PUSHJ   P,OUTCH2        ;OUTPUT THE PHONY CHAR
1683:         ADDI    HPOS,1          ;COUNT THE OUTPUTS
1684:         TRNE    HPOS,7          ;ENOUGH?
1685:         JRST    OUTC1B          ;NO. MORE.
1686:         POPJ    P,              ;NO MORE
1687: 
1688: 
1689:                         ;CALLED AT UUO AND INT LEVEL
1690:                         ;TO ADJUST HPOS FOR OUTPUT OF CHR
1691:                         ;SKIPS IF SPCHECK SAYS SPECIAL CHAR
1692: 
1693: ADJHP:  PUSHJ   P,SPCHEK        ;GET BITS FROM SPCTAB
1694:         AOJA    HPOS,CPOPJ      ;ORDINARY CHAR.
1695:         CAIL    CHR,40  ;WHICH SPECIALS?
1696:         JRST    CPOPJ1          ;HIGH ONES
1697:         CAIN    CHR,15  ;CARRIAGE RETURN?
1698:         MOVEI   HPOS,0          ;YES.
1699:         CAIE    CHR,11  ;TAB?
1700:         JRST    CPOPJ1          ;NO. NO HP MOD
1701:         TRO     HPOS,7          ;TAB. TO NEXT 8
1702:         AOJA    HPOS,CPOPJ1
    TTYSER page# 0028 next  prev
1704: ;PUTCHI, PUTCHO
1705: ;ROUTINE TO PUT A CHARACTER INTO A BUFFER (FOR INPUT,MERTPO, AND ONCE)
1706: ;CALL   MOVEI DAT,TTXBUF(DDB)           ;TO SPECIFY BUFFER
1707: ;       PUSHJ   P,PUTCHI
1708: ;       ERROR RETURN, BUFFER "FULL"
1709: ;       SUCCESSFUL RETURN
1710: 
1711: PUTCHI:
1712:         SOSG    FCTR(DAT)               ; ANY FREE SPACES LEFT?
1713:         JRST    PUTCI0                  ;NO
1714: PUTCHA: SOSLE   PCTR(DAT)               ;LAST BYTE IN BUFFER FILLED?
1715:         JRST    PUTCI1                  ;NO. GO AHEAD
1716:         PUSH    P,TAC
1717:         MOVE    TAC,BUF(DAT)            ;GET ADR AND SIZE OF BUFFER
1718:         HLRZM   TAC,PCTR(DAT)           ;INITIAL COUNTER
1719:         HRRM    TAC,PUTR(DAT)           ;BYTE POINTER.
1720:         POP     P,TAC                   ;RESTORE TAC
1721: PUTCI1: IDPB    CHR,PUTR(DAT)
1722:         JRST    CPOPJ1
1723: 
1724: ;ROUTINE TO STUFF MONITOR ERROR MESSAGE IN TTI BUFFER
1725: ;CALLED IN LINE FROM PUTCHO
1726: 
1727: TTIOUT: MOVE    IOS,DEVIOS(DDB)
1728:         AOS     TOFCTR(DDB)             ;RE-ADJUST FREE CHAR COUNT
1729:         TRNN    IOS,MERTPO              ;MONITOR ERROR MESSAGE?
1730:         JRST    GETCH1                  ;NO, ZERO CHR TO INDICATE
1731:         TRON    IOS,MERTP1              ;TEST FLAG AND SET IF NOT ON
1732:         PUSHJ   P,SETBFI                ;CLEAR INPUT
1733:         MOVEM   IOS,DEVIOS(DDB)         ;AND MAKE SURE FLAG GETS ON
1734:         MOVEI   DAT,TTIBUF(DDB)         ;YES, PUT REST IN TTI BUFFER
1735:         PUSHJ   P,PUTCHI
1736:         POPJ    P,                      ;ERROR RETURN
1737:         POPJ    P,
1738: 
1739: ;ROUTINE TO PLACE A CHARACTER INTO THE OUTPUT BUFFER
1740: ;CALLED AT INTERRUPT LEVEL 
1741: ;CALL   MOVE    CHR,CHARACTER TO PLACE INTO BUFFER
1742: ;       PUSHJ   P,PUTCHO
1743: ;       ONLY RETURN, WHETHER OR NOT CHARACTER WAS PLACED
1744: 
1745: PUTCHO: PUSH    P,TAC
1746:         LDB     TAC,PUNIT
1747:         HLL     TAC,LINTAB(TAC)
1748:         TLNE    TAC,TTYFIL              ;FILLING THIS TTY?
1749:         JRST    FILLCR
1750: FILNCR: TLNN    TAC,FCS
1751:         JRST    PUTCNV                  ;NOT FULL CHAR SET - CONVERT LOWER TO UPPER
1752: PUTNLC: POP     P,TAC
1753: PUTCRS: SOSG    TOFCTR(DDB)             ;RETURN IMMEDIATELY IF NO ROOM
1754:         JRST    TTIOUT                  ;UNLESS MONITOR ERROR MESSAGE
1755:         SOSLE   TOPCTR(DDB)             ;LAST BYTE IN BUFFER?
1756:         JRST    PUTCO1                  ;NO. GO ON.
1757:         PUSH    P,TAC                   ;SAVE AN AC
1758:         MOVE    TAC,TTOBUF(DDB)         ;GET COUNT AND ADDRESS
1759:         HLRZM   TAC,TOPCTR(DDB)         ;INITIAL COUNTER
1760:         HRRM    TAC,TOPUTR(DDB)         ;INITIAL POINTER
1761:         POP     P,TAC                   ;RESTORE AC
1762: PUTCO1: IDPB    CHR,TOPUTR(DDB)         ;PUT CHARACTER INTO BUFFER
1763:         POPJ    P,
1764: 
1765: FILLCR: CAIE    CHR,15
1766:         JRST    FILNCR
1767:         LDB TAC,PIOMOD                  ;GET IO MODE
1768:         CAIE TAC,10
1769:         CAIN TAC,11
1770:         JRST FILNCR                     ;DON'T FILL IN IMAGE MODE
1771:         MOVEI   TAC,10
1772:         EXCH    TAC,(P)
1773: PUTCRX: PUSHJ   P,PUTCRS
1774:         JUMPE   CHR,CRFULL
1775:         SOSLE   (P)                     ;DONE YET?
1776:         JRST    PUTCRX                  ;NO
1777: CRFULL: POP     P,(P)
1778:         POPJ    P,
1779: 
1780: PUTCNV: CAIL    CHR,"a"
1781:         CAILE   CHR,"z"
1782:         JRST    PUTNLC
1783:         ANDCMI  CHR,40                  ;CONVERT TO UPPER CASE
1784:         JRST    PUTNLC
    TTYSER page# 0029 next  prev
1786: ;GETCHR, GETCHY
1787: ;CHARACTER AND BUFFER HANDLING ROUTINES
1788: 
1789: ;ROUTINE TO PICK UP A CHARACTER FROM ANY BUFFER
1790: ;CALL   MOVEI   DAT,TTXBUF(DDB)         ;TO SPECIFY BUFFER
1791: ;       PUSHJ   P,GETCHR
1792: ;       ONLY RETURN                     ;CHARACTER OR ZERO IN CHR
1793: ;                                       ;ZERO INDICATES BUFFER "EMPTY"(TAKR=PUTR)
1794: 
1795: GETCHR:PUSHJ P,GETCHY
1796:         ANDI CHR,177            ;THROW OUT CONTROL BITS.
1797:         POPJ P,
1798: 
1799: GETCHY: 
1800:         HLRZ CHR,BUF(DAT)               ;CHARS IN BUFFER (THIS IS A BUG TRAP!!)
1801:         CAIN CHR,TTICHR                 ;TTICHR FOR INPUT.
1802:         JRST GETCHA
1803:         PUSHACS
1804:         PUSH P,LINE
1805:         PUSHJ P,DISMES
1806:         ASCIZ /TTY/
1807:         POP P,TAC
1808:         PUSHJ P,DISLOC
1809:         PUSHJ P,DISMES
1810:         ASCIZ / AT GETCHY FOR OUTPUT
1811: /
1812:         POPACS
1813:         DEBCHECK
1814:         JRST GETCHO
    TTYSER page# 0030 next  prev
1816: ;GETCHA, GETCHO
1817: ; ROUTINE TO GET CHARACTER
1818: 
1819: GETCHA: SOSGE   TSYNC(DAT)              ;ALWAYS COME HERE FOR INPUT.
1820:         SETZM TSYNC(DAT)                ;DON'T LET IT GET NEGATIVE
1821:         LDB     CHR,[POINT PUNITS,-TTIBUF+DEVCHR(DAT),35-PUNITP]
1822:         CAIL    CHR,DPYL0
1823:         CAILE   CHR,DPYL0+DPYNUM+DDNUM-1
1824:         JRST    GETCHO
1825:         HLRZ    CHR,LETAB-DPYL0(CHR)
1826:         TRNN    CHR,WTFLAG
1827:         JRST    GETCHO          ; IF LINED NOT WAITING, JUST LEAVE WITH THE GOODS
1828:         PUSHJ   P,GETCHO                ; GET CHARACTER
1829:         PUSHACS
1830:         LDB     DAT,[POINT PUNITS,-TTIBUF+DEVCHR(DAT),35-PUNITP]
1831:         PUSHJ   P,ACTIV3
1832:         POPACS
1833:         POPJ    P,
1834: 
1835: GETCHO:                ;7 BIT BYTES ALREADY (OUTPUT)
1836: GETCHX: MOVE    CHR,TCTR(DAT)           ; GET TAKR BUFFER
1837:         CAMN    CHR,PCTR(DAT)           ;IS IT SAME AS PUTR(BUFFER EMPTY)?
1838:         JRST    GETCH1                  ;YES, LOAD CHR WITH ZERO AND EXIT
1839:         SOSLE   TCTR(DAT)               ;NO, ARE WE AT END OF BUFFER?
1840:         JRST    GETCH2                  ;NO. GO ON.
1841:         MOVE    CHR,BUF(DAT)            ;YES. START AT TOP AGAIN
1842:         HLRZM   CHR,TCTR(DAT)           ;INITIAL COUNTER
1843:         HRRM    CHR,TAKR(DAT)           ;INITIAL POINTER
1844: GETCH2: ILDB    CHR,TAKR(DAT)           ;GET CHARACTER
1845:         AOS     FCTR(DAT)               ;INCREMENT FREE CHAR. COUNT
1846:         JUMPE   CHR,GETCHX              ;SKIP NULLS
1847:         POPJ    P,
1848: GETCH1: TDZA    CHR,CHR         ;RETURN 0 INDICATING END OF BUFFER
1849: PUTCI0: AOS     FCTR(DAT)               ;FIX FREE COUNTER
1850:         POPJ    P,
    TTYSER page# 0031 next  prev
1852: ;TSETBF, SETBFI, SETBF3, SETBFO
1853: ;ROUTINES TO SET UP BUFFERS
1854: 
1855: TSETBF:
1856:         PUSHJ   P,SETBF2                ; INIT TTO BUFFER
1857: 
1858: SETBFI:MOVE    DAT,J                   ; SAVE J
1859:         LDB J,PJOBN                     ; GET JOB #
1860:         JUMPE J,SETBF4
1861:         MOVSI TAC,COMSNB
1862:         PUSHJ P,CLRSIN                  ; CLEAR FROM SWAPIN LIST FOR COMMAND
1863: SETBF4: MOVE J,DAT                      ; RESTORE J
1864:         MOVEI   DAT,1
1865:         DPB     DAT,PCOMIC
1866:         DPB     DAT,PLSTLC
1867:         MOVEI   DAT,TTIBUF(DDB)         ;SPECIFY USER MODE INPUT BUFFER
1868:         SETZM   TISYNC(DDB)             ;NO LINES IN BUFFER
1869:         HRLI TAC,1100           ;9 BIT BYTES IN INPUT BUFFER !!
1870:         JRST    SETBF0                  ;INIT BUFFER
1871: SETBF3:PUSHJ P,XMTIN4          ;MAKE SURE GUY ISN'T HUNG ON OUTPUT.
1872: SETBF2: MOVEI   DAT,TTOBUF(DDB)         ;SPECIFY OUTPUT BUFFER
1873: SETBFO:HRLI TAC,700            ;7 BIT BYTES IN OUTPUT BUFFER.
1874: SETBF0: HRR     TAC,BUF(DAT)
1875:         MOVEM   TAC,TAKR(DAT)
1876:         MOVEM   TAC,PUTR(DAT)
1877:         MOVEI TAC,1
1878:         MOVEM   TAC,TCTR(DAT)           ;SO FIRST SOSG DOESNT SKIP
1879:         MOVEM   TAC,PCTR(DAT)
1880:         HLRZ    TAC,BUF(DAT)            ;CHARACTER COUNT
1881:         MOVEM   TAC,FCTR(DAT)           ;UPDATE FREE CHARACTER COUNT
1882:         POPJ    P,
    TTYSER page# 0032 next  prev
1884: ;SPCHEK, SPCACT
1885: ;ROUTINE TO CHECK IF A CHARACTER IS SPECIAL(ASCII 0-37, 175-177)
1886: ;CALL   MOVE    CHR,CHAR. TO BE CHECKED
1887: ;       PUSHJ   P,SPCHEK
1888: ;       RETURN1 IF REGULAR ASCII CHAR (40-174), C(TAC)=0
1889: ;       RETURN2 IF SPECIAL CHAR., TAC LOADED WITH WORD FROM SPCTAB
1890: 
1891: SPCHEK:LDB TAC,[POINT 7,CHR,35]        ;GET CODE WITHOUT CTRL BITS.
1892:         SKIPE   TAC,SPCTAB(TAC)
1893:         TLNN TAC,SPCBTS         ;MAYBE A SPECIAL...
1894:         POPJ P, ;NOT SPECIAL, AFTER ALL.
1895:         JRST    CPOPJ1
1896: 
1897: ;SPECIAL CHARACTER TABLE
1898: ;FORMAT XWD BITS+CHAR,ADRESS OF ROUTINE
1899: ;HIGH ORDER BITS IN LH:
1900: 
1901: SPACTN←←400000          ;SPECIAL ACTION TO BE TAKEN
1902: ALLSPA←←200000          ;ALWAYS CONTROL FUNCTIONS, NEVER BREAK CHARACTERS.
1903: SPOUT←←100000           ;SPECIAL HANDLING ON UUO OUTPUT
1904: IMLCHR←←40000           ;NOT SPECIAL ON IMLACS EVEN IF ALLSPA IS ON.
1905: BREAKB←←20000          ;BREAK CHARACTER
1906: SPHPOS←←10000           ;CHARACTER AFFECTS HORIZONTAL POSITION
1907: FCSBRK←←4000            ;BREAK CHARACTER IN FCS(100) MODE
1908: ECHSUP←←2000            ;SUPRESS ECHO OF CHAR ITSELF
1909: SPBKDS←←1000            ;PERFORM SPECIAL ACTION EVEN WITH CTRL. BITS.
1910: LETTER←←400
1911: NUMBER←←200
1912: LNUMBT←←LETTER!NUMBER   ;A LETTER OR DIGIT.
1913: 
1914: SPCBTS←←SPACTN!SPOUT!BREAKB!SPHPOS!FCSBRK
1915: 
1916: DEFINE SPC(U,L,X){FOR Z←U,L {X
1917:                               }
1918:                   }
1919: 
1920: SUPBTS←←1               ;SUPRESS ACTIVATION ON CONTROL BITS.
1921: SUPCCR←←2               ;SUPRESS EFFECT OF CONTROL CR TO LINE EDITOR
1922: SUPSCM←←4               ;SUPRESS SUPBTS (ACTIVATE ANYWAY) IF CTRL-META
1923: 
1924: SPCACT:
1925:         LDB TAC,[POINT 7,CHR,35]
1926:         JUMPE TAC,CPOPJ         ;ALWAYS ACTIVATE ON ↑C
1927:         PUSH P,LINE
1928:         IDIVI TAC,=36
1929:         ADDI TAC,(DDB)
1930:         MOVE TAC,ACTBTS(TAC)
1931:         LSH TAC,(LINE)
1932:         MOVE LINE,ACTMOD(DDB)
1933:         TLNE TAC,400000
1934:         JRST TTPOP
1935:         TRNE LINE,SUPSCM
1936:         CAIE UCHN,3
1937:         TRNN LINE,SUPBTS
1938:         JUMPG UCHN,TTPOP
1939:         AOS -1(P)
1940: TTPOP:  POP P,LINE
1941:         POPJ P,
    TTYSER page# 0033 next  prev
1943: ;SPCTAB
1944: SPCTAB: XWD     ALLSPA+SPACTN+ECHSUP+BREAKB+SPBKDS,CONTC        ;↑C
1945:         0                                       ;↑A
1946:         XWD     ALLSPA+SPACTN+ECHSUP+IMLCHR,CONTB       ;↑B FULTWX&HOLD SW
1947:         0                                       ; β
1948:         0                                       ;↑D EOT
1949:         0                                       ;↑E WRU
1950: 0;      XWD     SPACTN+ECHSUP,CONTF             ;↑F FCS SW
1951:         0                                       ;↑G (BELL)
1952:         0                                       ;↑H OR BACKSPACE KEY
1953:         XWD     ALLSPA+SPACTN+SPHPOS+SPOUT+SPBKDS,CONTI ;↑I OR TAB
1954:         XWD     BREAKB+SPBKDS,0                 ;↑J OR LINE FEED
1955:         XWD     ALLSPA+SPACTN+SPOUT,CONTK       ;↑K OR VERT TAB
1956:         XWD     ALLSPA+SPACTN+SPOUT,CONTL       ;↑L OR FORM FEED
1957:         XWD     ALLSPA+SPACTN+SPHPOS+SPBKDS,CRLF;↑M OR CARRIAGE RETURN
1958:         0                                       ;↑N
1959:         XWD     SPACTN,CONTO                    ;↑O SUPP OUTPUT
1960: 0;      XWD     SPACTN+ECHSUP,CONTP             ;↑P T35 SW
1961:         0                                       ;↑Q XON (PAPERTAPE)
1962:         0                                       ;↑R TAPE PUNCH ON
1963:         0                                       ;↑S XOFF
1964:         0                                       ;↑T TAPE PUNCH OFF
1965:         XWD     SPACTN,CONTU                    ;↑U DELETE LINE
1966:         0                                       ;↑V OR IDLE
1967:         0                                       ;↑W
1968:         0                                       ;↑X
1969:         0                                       ;↑Y
1970:         XWD     ALLSPA+SPACTN+ECHSUP+IMLCHR,CONTZ       ;↑Z TTY EOF
1971:         0                                       ;ASCII 33 (OLD ALT-MODE)
1972:         0                                       ;ASCII 34
1973:         0                                       ;ASCII 35
1974:         0                                       ;ASCII 36
1975:         0                                       ;ASCII 37
1976: 
1977: SPC (" ","0"-1,0)
1978: SPC ("0","9",<XWD NUMBER,0>)
1979: SPC ("9"+1,"A"-1,0)
1980: SPC ("A","Z",<XWD LETTER,0>)
1981: SPC ("Z"+1,"a"-1,0)
1982: SPC ("a","z",<XWD LETTER,0>)
1983: SPC ("z"+1,174,0)
1984: 
1985:         XWD     ALLSPA+SPACTN+BREAKB+ECHSUP,ALTMOD      ;OLD DEC ALTMODE 175
1986:         0                                               ;CLOSE CURLY BRACKET
1987:         XWD     SPACTN+ECHSUP+FCSBRK+SPBKDS,RUBOUT      ;177 RUBOUT
1988: 
    TTYSER page# 0034 next  prev
1990: ;TTYUUO, CLRBUF, INSKIP
1991: ;TTYUUO - QUANTITY IN AC FIELD DETERMINES ACTION OF UUO (051)
1992: 
1993: TTYUUO:
1994:         CAIL    UCHN,TTUUOL             ;TOO HIGH AC FIELD?
1995:         POPJ    P,                      ;YES, NO-OP
1996:         PUSHJ   P,TTYFNU
1997:         HLRZ TAC,TTUUOT(UCHN)           ;GET BITS
1998:         TLNE    IOS,TTYDTC
1999:         TRNE TAC,200000                 ;DO WE CALL ROUTINE IF DETACHED?
2000:         CAIA                            ;YES
2001:         POPJ    P,                      ;QUIT NOW
2002:         SKIPG   TTUUOT(UCHN)            ;IS IT AN INPUT TYPE ?
2003:         PUSHJ   P,UNSUPR                        ;YES. TURN OFF CTRL. O.
2004:         JRST    @TTUUOT(UCHN)           ;DISPATCH TO UUO ROUTINES
2005: 
2006: DEFINE UUOS{FOR X IN(<INCHRW,600000>,<OUTCHR,,ONEOUT>,<INCHRS,600000>,<OUTSTR>
2007: ,<INCHWL,600000>,<INCHSL,600000>,GETLIN,<SETLIN>
2008: ,<RESCAN,,TRESCU>,<CLRBFI,,CLRBUF>,<CLRBFO,,SETBF3>,<INSKIP,600000>
2009: ,<INWAIT,600000,IWAIT>,SETACT,<TTREAD,200000>,OUTFIV)}
2010: 
2011: UUOMAC TTUUOT,TTYUUO
2012: TTUUOL←←UUOCNT
2013: 
2014: CLRBUF: TLNE    IOS,TPMON               ;NOT ALLOWED IN MONITOR MODE!
2015:         POPJ    P,                      ;JUST RETURN
2016:         TLNE    LINE,IMLIN
2017:         JRST    IMLCLR
2018:         PUSHJ   P,SETBFI                        ;CLEAR INPUT BUFFER
2019:         TLNE    LINE,DDDLIN!DISLIN      ;THAT'S ALL FOR TTY'S
2020:         SKIPL   TAC,LETAB-DPYL0(LINE)           ;DOES HE HAVE A LINE EDITOR
2021:         POPJ    P,                              ;NO, DONE
2022:         MOVEI   CHR,10044                       ;GET A CLEAR
2023:         SETZ    UCHN,                           ;WITH NO BITS
2024:         JRST    PTLL3                           ;AND SEND IT DOWN THE TUBES
2025: 
2026: IMLCLR: MOVE    CHR,[ASCID/π/]          ;TELL IMLAC TO CLEAR ITS BUFFER.
2027:         PUSHJ   P,FIVOUT
2028:         PUSHJ   P,SETBFI                ;CLEAR OURS
2029:         MOVSI   IOS,IMLTTY
2030:         ANDCAB  IOS,DEVIOS(DDB)         ;AND THE BUCKY-BIT KLUDGE.
2031:         POPJ    P,
2032: 
2033: INSKIP: TRNE UUO,1
2034:         SKIPLE TISYNC(DDB)              ;INSKIP 1 WAITS FOR A WHOLE LINE
2035:         TLNE    IOS,TTYDTC!TPMON
2036:         POPJ    P,
2037:         MOVE    TAC,TIPUTR(DDB)
2038:         CAME    TAC,TITAKR(DDB) ;ANY CHARS. IN INPUT BUFFER ?
2039:         JRST    CPOPJ1          ;YES. SKIP RETURN.
2040:         TLNN    LINE,DDDLIN!DISLIN      ;THAT'S ALL UNLESS HE'S A DPY
2041:         POPJ    P,
2042:         SKIPGE  TAC,LETAB-DPYL0(LINE)   ;ANYTHING IN LINE EDITOR
2043:         SKIPG   CCPOS(TAC)              ;I.E. CURSOR NOT AT LEFT
2044:         POPJ    P,                      ;NO
2045:         JRST    CPOPJ1                  ;YES, SKIP RETURN
    TTYSER page# 0035 next  prev
2047: ;INCHSL, INCHRS, INCHWL, IWAIT, OUTSTR, INCHGT, INCHGB
2048: ;INPUT A CHARACTER AND SKIP---IF NONE TYPED, DON'T SKIP
2049: 
2050: INCHSL: SKIPG   TISYNC(DDB)             ;ANY LINES IN BUFFER?
2051:         POPJ    P,                      ;NO, RETURN
2052: INCHRS:
2053:         TLNE    IOS,TPMON
2054:         POPJ    P,
2055:         PUSHJ   P,INCHGT                ;GET ANY CHRS. FROM LINE EDITOR.
2056:         MOVEI   DAT,TTIBUF(DDB)         ;GET A CHARACTER
2057:         PUSHJ   P,GETCHY                ;FROM TTI BUFFER
2058:         PUSHJ   P,PTICHK                ;WAKE UP PTY WAITERS, IF ANY.
2059:         JUMPE   CHR,CPOPJ               ;RETURN IF NULL(EMPTY BUFFER)
2060:         CAIN    CHR,600
2061:         JRST    INCHSZ                  ;STORED ↑C
2062: INCHSY: XCTR    XW,[MOVEM CHR,(UUO)]    ;MOVE INTO LOC. SPECIFIED BY UUO
2063:         JRST    CPOPJ1                  ;AND SKIP RETURN
2064: 
2065: INCHSZ: MOVE    CHR,DEVMOD(DDB)
2066:         TLNN    CHR,TTYATC              ;IF ATTACHED TO JOB
2067:         TRNN    CHR,ASSCON!ASSPRG       ;OR NOT ASSIGNED OR INITED
2068:         JRST    MONUS6                  ;THEN PROCESS CONTROL-C
2069:         JRST    INCHSY                  ;GIVE THE LOSER THE CONTROL-C
2070: 
2071: ;INPUT CHARACTER AND WAIT, LINE MODE
2072: 
2073: INCHWL: PUSHJ   P,INCHSL                ;SEE IF ANY CHARS.
2074:         JRST    .+2                     ;NO
2075:         POPJ    P,0                     ;YES. GIVE IT TO USER
2076:         TLNE    LINE,IMLIN              ;BY BO - IMLACS HAVE A COMMAND
2077:         JRST    IMCHWL                  ;FOR SPECIAL ACTIVATION.
2078: IMCHW0: MOVE    IOS,[XWD TTYIOW,IOACT]  ;NONE. WAIT FOR IT
2079:         IORM    IOS,DEVIOS(DDB)         ;TTY TO IOW STATE
2080:         MOVSI   IOS,DDTM                ;JUST IN CASE
2081:         ANDCAB  IOS,DEVIOS(DDB)         ;CLEAR DDTMODE BREAK FLAG
2082:         PUSHJ   P,TWSYNC                ;WAIT FOR CHAR(INTPTI IF APPROPRIATE).
2083:         PUSHJ   P,INCHSL                ;REPEATED TESTING HERE SO
2084:         JRST    IMCHW0                  ;IMLACS ONLY GET THE WORD-MODE
2085:         POPJ    P,                      ;COMMAND ONCE.
2086: 
2087: IMCHWL: TLNN    LINE,SPCBRK             ;IMLAC: SPECIAL ACTIVATION MODE?
2088:         JRST    IMCHW0
2089:         MOVE    CHR,[ASCID/α/]          ;YES.  TELL IT WE'RE WAITING.
2090:         PUSHJ   P,FIVOUT
2091:         JRST    IMCHW0
2092: 
2093: IWAIT:  LDB CHR,PLASTC          ;GET LENGTH OF LAST RE-EDITED LINE.
2094:         TRNE UUO,-1             ;IS ADDRESS OF IWAIT 0 ?
2095:         XCTR    XW,[MOVMM CHR,(UUO)]    ;NO. USER WANTS GOOD NUMBER.
2096:         SKIPLE  TISYNC(DDB)     ;IS THERE A LINE PRESENT ?
2097:         TLNE    IOS,TPMON       ;NOTHING IN MONITOR MODE
2098:         CAIA
2099:         POPJ    P,
2100:         MOVE    IOS,[XWD TTYIOW,IOACT]
2101:         IORM    IOS,DEVIOS(DDB)
2102:         MOVSI   IOS,DDTM
2103:         ANDCAB  IOS,DEVIOS(DDB)
2104:         PUSHJ   P,TWSYNC
2105:         JRST    IWAIT
2106: 
2107: ;OUTPUT A STRING--AT PRESENT LIKE DDTOUT
2108: 
2109: OUTSTR: JRST    DDT5                    ;TO BE NEW ROUTINE
2110: 
2111: INCHGT: TLNN    LINE,DISLIN!DDDLIN      ; ONLY DPY'S
2112:         POPJ    P,
2113:         MOVE    TAC,TITAKR(DDB)
2114:         CAME    TAC,TIPUTR(DDB)         ;WILL HE GET A CHAR. WITHOUT ACTIVATING THE LINE EDITOR?
2115:         POPJ    P,              ;YES
2116: INCHGB: SKIPGE  TAC,LETAB-DPYL0(LINE)   ;ANYTHING IN LINE EDITOR?
2117:         SKIPG   CCPOS(TAC)              ;IS POINTER INTO LINE?
2118:         POPJ    P,                      ;NO
2119:         JRST    LACTIV                  ;WILL TRANSFER SOME RIGHT NOW!
2120:                                         ;IF THERE ARE ANY!
    TTYSER page# 0036 next  prev
2122: ;INCHRW, ONEOUT, GETLIN, SETLIN, SYNCHK, SYNCHA, SETACT
2123: ;MORE ROUTINES CALLED BY TTY UUO DISPATCHER
2124: 
2125: ;INCHRW GOES INTO I/O WAIT IF NO CHARACTER HAS BEEN TYPED--NO SKIPS
2126: 
2127: INCHRW: PUSHJ   P,INCHRS                ;GET ACHAR IF ONE IS THERE
2128:         JRST    .+2                     ;NONE THERE
2129:         POPJ    P,                      ;CHAR. PICKED UP AND STORED
2130:         TLNE    LINE,IMLIN              ;BY BO - IMLACS HAVE FANCY
2131:         JRST    IMCHRW                  ;COMMAND FOR THIS.
2132: IMCHR0: MOVE    IOS,[XWD TTYIOW+DDTM,IOACT]     ;SETUP FOR IOWAITM
2133:         IORB    IOS,DEVIOS(DDB)         ;SPECIFICALLY FOR INPUT WAIT
2134:         PUSHJ   P,TWSYNC                ;WAIT FOR CHAR. TO BE TYPED
2135:         JRST    INCHRW                  ;GO GET IT
2136: 
2137: IMCHRW: MOVE    CHR,[ASCID/↓/]          ;IMLAC COMMAND: SEND ONE CHAR.
2138:         PUSHJ   P,FIVOUT
2139:         JRST    IMCHR0
2140: 
2141: ;ONEOUT OUTPUTS ONE CHARACTER
2142: 
2143: ONEOUT: XCTR    XR,[MOVE CHR,(UUO)]     ;PICK UP CHAR. FROM USER
2144:         TRNE    IOS,IOSUPR              ;IF ↑O MODE
2145:         POPJ    P,0                     ;RETURN
2146:         ANDI    CHR,177                 ;MASK ANY JUNK
2147:         JUMPE   CHR,CPOPJ               ;DONT STORE NULLS
2148:         PUSHJ   P,OUTCHR                ;PLACE IT IN TTO BUFFER
2149:         JUMPN   CHR,TYPGO               ;IF IT STORED, RETURN
2150:         PUSHJ   P,TTOUWS                ;BUFFER WAS FULL. TRY AGAIN LATER
2151:         JRST    ONEOUT
2152: 
2153: ;GETLIN PUTS LINE CHARACTERISTICS WORD INTO ADR. IN UUO ADR. FIELD
2154: 
2155: GETLIN: XCTR    XR,[SKIPGE TAC,(UUO)]   ;DOES USER WANT OWN LINE CHAR. WD.?
2156:         JRST    GETLN1                  ;YES
2157:         MOVEI   LINE,0                  ;NO, CHECK SIZE OF NUMBER
2158:         CAIL    TAC,TTPLEN              ;TOO HIGH?
2159:         SOJL    LINE,GETLN3
2160:         MOVE    LINE,LINTAB(TAC)        ;NO, GET IT
2161:         HRRI    LINE,(TAC)
2162: GETLN1: MOVE    TAC,LINE        ;START WITH THIS LINE
2163:         JRST    GETLN5          ;JUMP IN
2164: GETLN2: TLNN    TAC,PTYLIN              ;IS THIS A PTY?
2165:         JRST    GETLN4
2166:         MOVE    TAC,PTYJOB-PTYL0(TAC)   ;OWNER OF THIS PTY
2167:         MOVE    TAC,JBTLIN(TAC)         ;HIS LINE CHARACTERISTICS
2168: GETLN5: CAME    TAC,[-1]                ;THAT'S ALL IF WE FIND A DETACHED LINE
2169:         JRST    GETLN2          ;DOWN THE CHAIN
2170:         JRST    GETLN3
2171: GETLN4: AND     TAC,[XWD DISLIN!DDDLIN,0]       ;COPY THESE BITS
2172:         TDO     LINE,TAC                        ;INTO LINE BITS, IN CASE WE ARE A PTY
2173: GETLN3: XCTR    XW,[MOVEM LINE,(UUO)]           ;GIVE IT TO USER
2174:         POPJ    P,
2175: 
2176: ;ROUTINE TO SET LINE CHARACTERISTICS THAT ARE SETABLE
2177: 
2178: SETLIN: MOVSI   TAC,LGLSET&¬IMPBIT      ;MAKE MASK OF ALL OF THEM
2179:         TLNE    LINE,DISLIN!DDDLIN!PTYLIN!IMLIN
2180:         TLZ     TAC,TBXPND
2181:         ANDCAM  TAC,LINTAB(LINE)        ;SHUT OFF ALL SETABLE BITS
2182:         TLO     TAC,IMPBIT              ;THIS CAN BE TURNED ON BUT NOT OFF
2183:         XCTR    XR,[AND TAC,(UUO)]      ;SET ONLY THOSE BITS USER WANTS SET
2184:         IORB    TAC,LINTAB(LINE)        ;SET RESULTANT
2185:         HLL     LINE,TAC                ;NEW BITS TO LINE
2186: SYNCHK: MOVE    AC1,TITCTR(DDB)         ;PREPARE TO SIMULATE GETCHY
2187:         MOVE    AC2,TITAKR(DDB) 
2188:         MOVEI   AC3,1                   ;ONE FOR FIRST CHAR.
2189:         SETZM   TISYNC(DDB)             ;IN CASE BUFFER EMPTY
2190: SYNCH2: CAMN    AC1,TIPCTR(DDB)         ;IS THIS THE END?
2191:         POPJ    P,                      ;YES, LEAVE
2192:         SOJG    AC1,SYNCH3              ;TEST FOR WRAP AROUND
2193:         HRR     AC2,TTIBUF(DDB)         ;RESET BYTE POINTER
2194:         HLRZ    AC1,TTIBUF(DDB)         ;AND TAKR COUNTER
2195: SYNCH3: ILDB    CHR,AC2                 ;PICK UP CHAR!
2196:         TLNE IOS,TPMON                  ;MONITOR DOESN'T GET ANY OF THIS
2197:         JRST SYNCH5
2198:         TLNN LINE,SPCBRK                ;ARE WE SPECIALLY ACTIVATING
2199:         JRST SYNCH1                     ;NO
2200:         LDB UCHN,[POINT 2,CHR,28]
2201:         PUSHJ P,SPCACT
2202:         JRST SYNCH4
2203:         AOJA AC3,SYNCH2
2204: SYNCH1: TRNE CHR,600                    ;CONTROL BITS?
2205:         JRST SYNCH4                     ;YES, ACTIVATE THESE SO FAR
2206: SYNCH5: PUSHJ P,SPCHEK
2207:         AOJA    AC3,SYNCH2
2208:         TLNE TAC,BREAKB!FCSBRK          ;BREAK CHARACTER?
2209: SYNCH4: MOVEM   AC3,TISYNC(DDB)         ;UPDATE TISYNC WITH # OF CHARS SCANNED SO FAR
2210:         AOJA    AC3,SYNCH2
2211: 
2212: SYNCHA: MOVN    AC1,FCTR(DAT)           ;UNUSED SPACE IN BUFFER.
2213:         ADDI    AC1,TTICHR              ;SIZE OF BUFFER
2214:         MOVEM   AC1,TSYNC(DAT)          ;SET TISYNC
2215:         POPJ    P,
2216: 
2217: 
2218: ;SETACT         SET A BREAK TABLE
2219: ;CALL
2220: ;TTYUUO 15,ADDR
2221: ;RIGHT HALF CONTAINS ADDRESS OF TABLE TO BE BLT'ED IN (NO NEW TABLE IF 0)
2222: ;LEFT HALF CONTAINS ADDRESS OF WHERE TO STORE COPY OF OLD TABLE(NO STORE IF 0)
2223: 
2224: SETACT: XCTR    XR,[MOVS TAC,(UUO)]     ;GET POINTER WORD
2225:         TRNN    TAC,-1
2226:         JRST    STACT1                  ;HE DOESN'T WANT TO KNOW WHAT HE HAD
2227:         MOVE    TAC1,ACTBTS(DDB)        ;GIVE HIM A COPY OF THE TABLE
2228:         XCTR    XW,[MOVEM TAC1,(TAC)]
2229:         MOVE    TAC1,ACTBTS+1(DDB)
2230:         XCTR    XW,[MOVEM TAC1,1(TAC)]
2231:         MOVE    TAC1,ACTBTS+2(DDB)
2232:         XCTR    XW,[MOVEM TAC1,2(TAC)]
2233:         MOVE    TAC1,ACTMOD(DDB)
2234:         XCTR    XW,[MOVEM TAC1,3(TAC)]
2235: STACT1: HLRZ    TAC1,TAC
2236:         JUMPE   TAC1,CPOPJ
2237:         XCTR    XR,[MOVE TAC,(TAC1)]    ;GET HIS NEW TABLE
2238:         MOVEM   TAC,ACTBTS(DDB)
2239:         XCTR    XR,[MOVE TAC,1(TAC1)]
2240:         MOVEM   TAC,ACTBTS+1(DDB)
2241:         XCTR    XR,[MOVE TAC,2(TAC1)]
2242:         MOVEM   TAC,ACTBTS+2(DDB)
2243:         XCTR    XR,[MOVE TAC,3(TAC1)]
2244:         MOVEM   TAC,ACTMOD(DDB)
2245:         POPJ    P,
    TTYSER page# 0037 next  prev
2247: ;OUTFIV, FIVOUT
2248: ;FIVOUT         ADDED BY BO FOR GIVING COMMANDS TO IMLACS
2249: ;       TTYUUO 17,ADR
2250: ;ADR: 5 LEFT-JUSTIFIED ASCII CHARACTERS.
2251: ;PUTS THESE CHARACTERS, UP TO THE FIRST NULL, INTO THE OUTPUT BUFFER.
2252: ;IF BIT 35 IS A ONE, PREFIXES THESE CHARS WITH A RUBOUT.
2253: ;GUARANTEES THAT THESE CHARS WILL BE SENT AS AN INDIVISIBLE BLOCK.
2254: 
2255: OUTFIV: XCTR    XR,[MOVE CHR,(UUO)]     ;TTYUUO 17 comes here,
2256:         PUSHJ   P,FIVOUT                ;other places in TTYSER go there.
2257:         POPJ P,
2258: 
2259: FIVOU2: CONO PI,SCNON
2260: FIVOU1: PUSHJ P,TTOUWS          ;Not enough room in buffer, so wait.
2261:         CAIA
2262: 
2263: FIVOUT: PUSH P,CHR              ;Make a temp cell for the data.
2264:         MOVEI AC3,6             ;Check for enough buffer space.
2265:         CAML AC3,TOFCTR(DDB)
2266:         JRST FIVOU1
2267: 
2268:         CONO PI,SCNOFF          ;Got room.  Turn off channel 5.
2269:         TLNE IOS,TTYDTC         ;Detached output gets flushed...
2270:         JRST TYPT1              ;...Ch. 5 back on.
2271: 
2272:         CAML AC3,TOFCTR(DDB)    ;Check again for room, this time with
2273:         JRST FIVOU2             ;the interrupt disabled.
2274: 
2275:         PUSHJ P,UNSUPR          ;You can't ↑O a command by God!
2276:         MOVSI TAC,(<POINT 7,(P),-1>)    ;Byte pointer into data.
2277: 
2278:         TRNN CHR,1              ;If bit 35 is on,
2279:         JRST FIVOU3
2280:         MOVEI CHR,177           ;give out with a rubout.
2281:         PUSHJ P,PUTCHO
2282: 
2283: FIVOU3: ILDB CHR,TAC            ;Fetch next char,
2284:         JUMPE CHR,FIVOU4        ;terminate on a null.
2285:         PUSHJ P,PUTCHO          ;Stuff into buff.
2286:         TLNE TAC,760000         ;5th chr in wrd?
2287:         JRST FIVOU3             ;No.  Do it again.
2288: 
2289: FIVOU4: CONO PI,SCNON           ;It's done like you wanted, Massa.
2290:         POP P,(P)               ;Chan. 5 is back, so is the stack.
2291:         JRST TYPGO
    TTYSER page# 0038 next  prev
2293: ;TTYMES
2294: ;A UUO TO SEND A MESSAGE TO ANOTHER TTY
2295: ;FROM 1,2 TO ANYONE OR FROM ANYONE TO THE CTY OR FROM ANYONE
2296: ;TO AN UNUSED TTY.
2297: TTYMES:
2298:         MOVE    UUO,TAC                 ;SAVE POINTER
2299:         XCTR    XR,[MOVE TAC,(UUO)]     ;PICK UP TTYNN OR LINE NUMBER
2300:         TLNN    TAC,770000              ;IS IT SIXBIT
2301:         JRST    TTYMS1                  ;NO
2302:         CAMN    TAC,['TTY   ']          ;GETTING HIS OWN?
2303:         JRST    [PUSHJ P,TTYFND         ;GET HIS TTY
2304:                 JRST TTYMS0]            ;AND SKIP THE REST
2305:         PUSHJ   P,GETDDB                ;FIND DDB FOR IT BY SIXBIT TTY NAME
2306:         POPJ    P,
2307:         JRST    TTYMS0
2308: 
2309: TTYMS1: MOVE    LINE,TAC                ;FOR GETDBA
2310:         PUSHJ   P,GETDBA                ;FIND DDB BY TTY LINE NUMBER
2311:         POPJ    P,                      ;NO DDB OR ERROR
2312: TTYMS0: XCTR    XR,[MOVE UUO,1(UUO)]    ;PICK UP POINTER
2313:         TLNN    UUO,770000              ;ALREADY GOT P FIELD?
2314:         TLO     UUO,440000              ;NO, MAKE IT PICK UP FIRST BYTE OF WORD
2315:         HLRZ    TAC,UUO
2316:         ANDI    TAC,7777                ;GET COUNT FIELD
2317:         TLZ     UUO,7777
2318:         TLO     UUO,700                 ;SET TO 7 BIT BYTES
2319:         JUMPN   TAC,.+2                 ;IS THERE A COUNT?
2320:         MOVEI   TAC,777777              ;NO, USE LARGE COUNT
2321:         XCTR    XW,[MOVEM TAC,JOBTM2]   ;SAVE COUNT IN USER CORE
2322:         MOVEI   DAT,TTOBUF(DDB)         ;SET-UP DAT
2323:         MOVE    IOS,DEVIOS(DDB)         ;MAKE SURE IOS IS SET UP.
2324:         AOS     (P)                     ;SKIP RETURN FROM HERE
2325:         PUSHJ   P,STLNAC                ;GET LINE CHARACTERISTICS. REG 7/20/73
2326:         TLNE    LINE,CTYLIN             ;IS THIS THE CTY THAT WE'RE TYPING ON?
2327:         JRST    TTYMS9                  ;YES.  USE DISASTER SERVICE FOR CTY.
2328: TTYMS3: XCTR    XRW,[SOSL CHR,JOBTM2]   ;COUNT OUT YET?
2329:         XCTR    XLB,[ILDB CHR,UUO]      ;NO. GET A CHAR.
2330:         JUMPLE  CHR,TYPGO               ;QUIT ON NULL, OR COUNT EXHAUSTED.
2331:         MOVNI   TAC,10                  ;TRY THIS MANY TIMES ON EACH CHAR.
2332:         XCTR    XW,[MOVEM TAC,JOBTM1]
2333: TTYMS4: MOVE    IOS,DEVIOS(DDB)         ;GET IOS
2334:         TDNE    IOS,[XWD TTYDTC,IOSUPR] ;DID SOMETHING HAPPEN?
2335:         POPJ    P,                      ;YES, FLUSH THE REST!
2336:         PUSHJ   P,OUTCHR
2337:         JUMPN   CHR,TTYMS3              ;LOOP IF CHAR PLACED
2338:         XCTR    XRW,[AOSLE JOBTM1]      ;COUNT DOWN LOSSAGE
2339:         JRST    TTYMS8                  ;COUNT OUT, LOSE ON THIS CHAR
2340:         PUSHJ   P,TYPTST                ;NO, TRY TO GET HIM GOING
2341:         LDB     TAC,PJOBN               ;PICK UP JOB NUMBER
2342:         MOVE    J,JOB(PID)              ;NEED THIS FOR SLEEP
2343:         CAMN    TAC,J                   ;DIFFERENT?
2344:         JRST    TTYMSW                  ;WAITING FOR OURSELVES IS SIMPLE
2345:         MOVEI   TAC,20
2346:         PUSHJ   P,SLEEPT                ;SLEEP 20 TIC'S
2347: TTYMSD: PUSHJ   P,STLNAC                ;SLEEP CLOBBERS THIS
2348:         XCTR    XLB,[LDB CHR,UUO]       ;GET CHAR. BACK
2349:         JRST    TTYMS4                  ;TRY AGAIN
2350: 
2351: TTYMSW: PUSHJ   P,DDTWAT
2352:         JRST    TTYMSD
2353: 
2354: TTYMS8: SOS     (P)                     ;HUNG TTY, GIVE LOSSAGE RETURN
2355:         POPJ    P,
2356: 
2357: ;HERE FOR SPECIAL CASE OF TYPING ON CTY.  REG 7/20/73
2358: TTYMS9: XCTR    XRW,[SOSL CHR,JOBTM2]   ;COUNT OUT YET?
2359:         XCTR    XLB,[ILDB CHR,UUO]      ;NO. GET A CHAR.
2360:         JUMPLE  CHR,CPOPJ               ;QUIT ON NULL, OR NEGATIVE COUNT.
2361:         PUSHJ   P,DISTYO                ;SEND CHARACTERS VIA DISASTER SERVICE
2362:         JRST    TTYMS9
    TTYSER page# 0039 next  prev
2364: ;TTREAD, TTYJNO, TTYJOB
2365: ;READ MICROSWITCH KEYBOARD USING SPCWAR MODE FEATURE
2366: ;CALL
2367: ;       TTYUUO 16,ADDR
2368: ;WHERE ADDR CONTAINS LINE NUMBER YOU WISH TO READ
2369: ;IF LINE IS ILLEGAL YOURS IS USED
2370: ;IF IT IS NOT ON THE KEYBOARD SCANNER THIS IS A NO-OP
2371: TTREAD: XCTR    XR,[SKIPL TAC,(UUO)]    ;PICK UP LINE HE WANTS
2372:         CAIL TAC,TTPLEN         ;HIGHER THAN HIGHEST?
2373:         HRRZ TAC,LINE           ;YES
2374:         SUBI TAC,DPYL0          ;NORMALIZE IT
2375:         JUMPL TAC,CPOPJ         ;NO-OP IF NOT ON KBD SCANNER
2376:         CAIL TAC,DPYNUM+DDNUM
2377:         POPJ P,
2378:         TRO TAC,100             ;SET SPW BIT
2379:         MOVEI AC3,20            ;TRY THIS MANY TIMES
2380: TTRED1: DATAO DKB,TAC
2381:         DATAI DKB,AC1           ;READ KBD
2382:         TRNN AC1,1B22           ;SHOULD HAVE SPW BIT ON
2383:         SOJG AC3,TTRED1         ;NO, TRY AGAIN
2384:         HLRZ AC2,AC1
2385:         CAIE AC2,-100(TAC)      ;DID WE GET THE RIGHT LINE?
2386:         SOJG AC3,TTRED1         ;NO
2387: TTRED3: XCTR    XW,[MOVEM AC1,(UUO)]    ;STORE RESULT
2388:         POPJ P,
2389: 
2390: ;TTYJOB
2391: ;CALL:
2392: ;       MOVEI AC,<LINE #>
2393: ;       TTYJOB AC,
2394: ;       <# OF JOB OWNING TTY IN AC>
2395: ;IF LINE # IS NOT TTY LINE, RETURN JOB CONTROLLING IF PTY
2396: TTYJNO:XCTR XR,[MOVE LINE,(UCHN)];GET ARG
2397:         JUMPL LINE,PTYJNO
2398:         CAIGE LINE,TTPLEN       ;LEGAL TTY LINE #?
2399:         SKIPN DDB,TTYTAB(LINE)  ;GET DDB POINTER
2400:         JRST TTYJN1             ;NONE
2401:         LDB TAC,PJOBN           ;GET JOB NUMBER
2402:         MOVE AC1,DEVMOD(DDB)    ;CHECK IF CONTROLLING JOB
2403:         TLNN AC1,TTYATC         ;JOBS CONSOLE?
2404:         TLO TAC,400000          ;NO, SET BIT TO INDICATE JUST OWNED
2405:         CAIA
2406: TTYJN1: SETZ TAC,               ;FLAG NO JOB
2407: TTYJN0: XCTR XW,[MOVEM TAC,(UCHN)];STORE ANSWER
2408:         POPJ P,
2409: 
2410: PTYJNO: MOVM LINE,LINE
2411:         CAIL LINE,TTPLEN
2412:         JRST PTYJN1
2413:         HRRE LINE,JBTLIN(J)     ;JOBS TTY
2414:         JUMPL LINE,TTYJN1       ;RETURN 0 IF NONE
2415: PTYJN1: HLL LINE,LINTAB(LINE)   ;GET LINE CHARACTERISTICS
2416:         TLNN LINE,PTYLIN        ;IS IT A PTY?
2417:         JRST TTYJN1             ;NO, NO CONTROLLING JOB
2418:         MOVE TAC,PTYJOB-PTYL0(LINE);CONTROLLING JOB
2419:         JRST TTYJN0
    TTYSER page# 0040 next  prev
2421: ;SNEAKS, SNEAKW, ACTCHR
2422: ;TWO UUO'S TO SEE THE NEXT CHAR. YOU WILL INPUT.
2423: ;ONE (SNEAKS) WHICH SKIPS IF A CHAR IS WAITING
2424: ;THE OTHER (SNEAKW) WAITS FOR A CHAR.
2425: ;BOTH RETURN THE CHAR. IN THE AC.
2426: 
2427: SNEAKS:
2428:         PUSHJ P,TTYFNU          ;FIND USERS TTY
2429:         TLNE IOS,TPMON!TTYDTC   ;DETACHED?
2430:         POPJ P,                 ;CAN'T GET ANYTHING IF DETACHED
2431:         MOVE AC2,TITAKR(DDB)
2432:         CAME AC2,TIPUTR(DDB)    ;ANYTHING IN TTY BUFFER
2433:         JRST SNLOAD             ;YES, RETURN IT
2434:         TLNE LINE,DISLIN!DDDLIN
2435:         SKIPL AC1,LETAB-DPYL0(LINE)
2436:         POPJ P,                 ;NOT DISPLAY, OR NOT ACTIVE
2437:         TLNE AC1,WTFLAG         ;IF TRANSFER IN PROGRESS, LOSE
2438:         JRST SNEAKX
2439:         SKIPG CCPOS(AC1)        ;CAN WE GET ANYTHING
2440:         POPJ P,                 ;NO
2441:         MOVE AC2,[POINT 7,LEBUF]
2442:         ADDI AC2,(AC1)          ;POINT TO BEGINNING OF LOSER EDITOR BUFFER
2443:         ILDB TAC,AC2
2444:         JUMPE TAC,.-1           ;LOOP FOR CHAR.
2445:         JRST SNLD1
2446: SNLOAD: MOVE TAC,TITCTR(DDB)
2447:         CAIG TAC,1
2448:         HRR AC2,TTIBUF+BUF(DDB) ;WRAP AROUND BUFFER
2449:         ILDB TAC,AC2
2450: SNLD1:  XCTR    XW,[MOVEM TAC,(UCHN)]   ;STORE RESULT
2451:         JRST CPOPJ1             ;RETURN
2452: 
2453: SNEAKX: PUSHJ P,WSCHED          ;WAIT ONE TIC
2454:         JRST SNEAKS             ;THEN LOOK AGAIN
2455: 
2456: SNEAKW:
2457:         PUSHJ P,SNEAKS
2458:         CAIA
2459:         POPJ P,                 ;SUCCESS
2460:         MOVE IOS,[XWD TTYIOW!SNKWAT,IOACT]
2461:         IORB IOS,DEVIOS(DDB)
2462:         MOVSI IOS,DDTM
2463:         ANDCAB IOS,DEVIOS(DDB)
2464:         PUSHJ P,TWSYNC          ;WAIT FOR CHAR.
2465:         JRST SNEAKW             ;TRY AGAIN
2466: 
2467: ;WAITS FOR ACTIVATION AND RETURNS THE CHAR WHICH ACTIVATED IT BUT
2468: ;ONLY ON RE-EDITED LINES
2469: 
2470: ACTCHR:PUSHJ P,TTYFNU          ;FIND USER'S TTY
2471:         CAME LINE,[-1]          ;DETACHED?
2472:         TLNN LINE,DDDLIN!DISLIN ;ONLY DPY'S HAVE ACT. CHAR.
2473:         JRST RTZERO             ;RETURN 0 (UUO NOT CLOBBERED YET)
2474:         MOVEI UUO,0             ;RPH & FW'S FAULT (NO STORE IN IWAIT)
2475:         PUSHJ P,IWAIT           ;WAIT FOR A LINE
2476:         MOVE CHR,LETAB-DPYL0(LINE)
2477:         LDB CHR,[POINT 9,GWORD(CHR),35]
2478:         XCTR    XW,[MOVEM CHR,(UCHN)]
2479:         POPJ P,
    TTYSER page# 0041 next  prev
2481: ;DDTIN
2482: IFN FTDDTM,<
2483: 
2484: ;INPUT TO DDT
2485: ;CALL AC,[SIXBIT /DDTIN/]       AC CONTAINS POINTER TO BUFFER AREA
2486: ;BUFFER AREA MUST BE 21 WORDS LONG
2487: 
2488: 
2489: DDTIN: PUSHJ   P,TTYFNU                ; SET UP DDB,LINE
2490: DDTINA: MOVE    IOS,[XWD TTYIOW+DDTM,IOACT]
2491:         IORB    IOS,DEVIOS(DDB)         ;PUT INTO I/O WAIT
2492:         TLNN    IOS,TPMON               ; NOTHING THERE I IN MONITOR MODE.
2493:         JRST    DDTINB
2494:         PUSHJ   P,TWSYNC
2495:         JRST    DDTINA
2496: DDTINB: TLNE    LINE,DDDLIN!DISLIN
2497:         PUSHJ   P,INCHGB                ;ACTIVATE LINE EDITOR, THEN WAIT ONE TIC IF NESCESARY.
2498:         PUSHJ P,PTICHK          ;CHECK FOR PTY LINKAGE.
2499:         MOVE    TAC,TIPUTR(DDB)
2500:         CAMN    TAC,TITAKR(DDB)         ;ANYTHING IN BUFFER?
2501:         PUSHJ   P,TWSYNC                ;NO, WAIT FOR SOME
2502: DDTIW:  MOVE    IOS,[XWD TTYIOW+DDTM,IOACT]
2503:         ANDCAB  IOS,DEVIOS(DDB)
2504:         MOVSI   TAC,IOFST
2505:         IORM    TAC,DEVIOS(DDB) ;STOP ALL IO
2506:         MOVSI   AC2,440700
2507:         HRR     AC2,@UUO        ;GET CONTENTS OF USER AC.
2508:         MOVE    LINE,TIPUTR(DDB)
2509:         MOVEI   DAT,TTIBUF(DDB)
2510:         MOVEI   AC1,<21*5>-1            ;NUMBER OF CHARACTERS ALLOWED
2511: XFRIN:  PUSHJ   P,GETCHY                ;TRANSFER INTO USER'S AREA
2512: XFRIN1: CAIN    CHR,600                 ;PRESTORED CONTROL C?
2513:         JRST    XFRIN0                  ;YES, GO INTO MONITOR MODE
2514:         XCTR    XDB,[IDPB CHR,AC2]
2515:         CAME    LINE,TITAKR(DDB)        ;PICKED UP ALL CHARACTERS YET?
2516:         SOJG    AC1,XFRIN               ;LOOP TILL DONE
2517: XFRIN2: MOVEI   CHR,0                   ;TERMINATE STRING
2518:         XCTR    XDB,[IDPB CHR,AC2]
2519: UNSUPR: MOVEI   IOS,IOSUPR              ;MAKE SURE IO NO LONGER SUPR.
2520:         ANDCAB  IOS,DEVIOS(DDB)
2521:         POPJ    P,
2522: 
2523: XFRIN0: MOVE    CHR,DEVMOD(DDB)         ;GET SOME GOOD BITS
2524:         TLNN    CHR,TTYATC
2525:         TRNN    CHR,ASSCON!ASSPRG       ;THESE GUYS CAN'T TYPE COMMANDS
2526:         JRST    DDTCNC
2527:         JRST    XFRIN
2528: 
2529: DDTCNC: PUSHJ   P,STLNAC                ;GET LINE CHARACTERISTICS
2530:         PUSHJ P,XFRIN2
2531:         JRST    MONUS6                  ;GO PROCESS ↑C
2532: >
    TTYSER page# 0042 next  prev
2534: ;DDTOUT, DDTWAT
2535: IFN FTDDTM,<
2536: ;OUTPUT FROM DDT
2537: ;CALL AC,[SIXBIT /DDTOUT/]      AC HAS POINTER TO DDT OUTPUT BUFFER
2538: 
2539: DDTOUT:
2540:         PUSHJ   P,TTYFNU
2541:         MOVE    UUO,@UUO
2542: >
2543: 
2544: DDT5:   HRLI UUO,440700
2545: DDT3:   MOVE IOS,DEVIOS(DDB)            ;GET IOS
2546:         TDNE IOS,[XWD TTYDTC,IOSUPR]    ;DID SOMETHING HAPPEN?
2547:         POPJ P,                         ;YES, FLUSH THE REST!
2548:         XCTR XLB,[ILDB CHR,UUO]
2549:         JUMPE CHR,TYPGO                 ;DONE, START OUTPUT
2550:         PUSHJ P,OUTCHR                  ;PLACE CHAR IN OUTPUT BUFFER
2551:         JUMPN CHR,DDT3                  ;LOOP IF CHARACTER WAS PLACED
2552:         ADD UUO,[XWD 070000,0]          ;BACK UP POINTER
2553:         PUSHJ P,TYPGO
2554:         PUSHJ P,DDTWAT
2555:         JRST DDT3
2556: 
2557: DDTWAT:MOVEI TAC,TTOCHR                ;SPECIFY TO WAIT TILL BUFFER IS EMPTY
2558:         DPB TAC,PFITCH                  ;IF DDT TYPE-OUT IS TOO LONG
2559:         MOVSI TAC,TTYIOW
2560:         ANDCAM TAC,DEVIOS(DDB)          ;MAKE SURE WE LOOK LIKE WE'RE IN OUTPUT WAIT!
2561:         MOVEI IOS,IOACT                 ;WAIT UNTIL MONITOR BUFFER EMPTY
2562:         IORB IOS,DEVIOS(DDB)
2563:         JRST WSYNC
    TTYSER page# 0043 next  prev
2565: ;SCNDSP, TTYIN, TWSYNC, TTYSKP
2566: ;DEVICE DEPENDENT PART OF IO UUOS.
2567: 
2568: ;DISPATCH TABLE
2569: 
2570:         JRST    TTYINI          ;INITIALIZATION
2571:         JRST    CPOPJ1          ;NO DO NOTHING
2572: SCNDSP:
2573:         JRST    TTYREL          ; RELEASE
2574:         JRST    OUT             ;CLOSE
2575:         JRST    TTYOUT          ;OUTPUT
2576: 
2577: TTYIN:  MOVE    IOS,[XWD TTYIOW,IOACT]  ;INDICATE INPUT WAIT
2578:         IORB    IOS,DEVIOS(DDB)
2579:         TLNE    IOS,TTYDTC
2580:         JRST    TTYIN2
2581:         MOVSI   TAC,TTYATC
2582:         TDNE    TAC,DEVMOD(DDB)
2583:         TLNN    IOS,TPMON
2584:         JRST    TTYIN3
2585: TTYIN2: PUSHJ   P,TWSYNC
2586:         JRST    TTYIN
2587: 
2588: TTYIN3: PUSHJ   P,PTICHK                ;CHECK PTY WAITERS.
2589:         MOVSI   IOS,DDTM+TPMON
2590:         ANDCAB  IOS,DEVIOS(DDB)
2591:         PUSHJ   P,STLNAC        ;GET LINE CHARACTERISTICS
2592: TTYIN1: SKIPG   TISYNC(DDB)
2593:         PUSHJ   P,TWSYNC
2594:         PUSHJ   P,MONUSR
2595:         MOVE    IOS,[XWD TTYIOW!DDTM,IOSUPR!MERTPO!MERTP1!IOACT]
2596: T0POPJ: ANDCAB  IOS,DEVIOS(DDB)
2597:         POPJ    P,
2598: 
2599: ;TTYSKP, SKIPS IF NEXT INPUT ON CHN WON'T HANG (MUST BE TTY)
2600: TTYSKP:CAMG UCHN,USRHCU
2601:         SKIPN DDB,USRJDA(UCHN)
2602:         JRST IOIERR
2603:         MOVE TAC,DEVMOD(DDB)
2604:         TLNN TAC,DVTTY          ;IS IT A TTY?
2605:         POPJ P,                 ;NO, GIVE HANG RETURN
2606:         MOVE IOS,DEVIOS(DDB)
2607:         TLNN IOS,TTYDTC         ;IF DETACHED,
2608:         SKIPG TISYNC(DDB)       ;OR NOTHING TO COME IN YET
2609:         POPJ P,                 ;WILL HANG
2610:         TLNE TAC,TTYATC         ;IF NOT USER CONSOLE,
2611:         TLNN IOS,TPMON          ;OR NOT IN MONITOR MODE
2612:         AOS (P)                 ;WON'T HANG
2613:         POPJ P,
2614: 
2615: ;TWSYNC IS CALLED FOR INPUT IO WAIT
2616: 
2617: TWSYNC: TLNN LINE,PTYLIN        ; NO, IS IT A PTY?
2618:         JRST TWSYN1             ; NO, JUST GO INTO WAIT
2619:         PUSH P,J
2620:         MOVE J,PTYJOB-PTYL0(LINE)
2621:         MOVSI AC1,INTPTI
2622:         TDNE AC1,JBTIEN(J)
2623:         PUSHJ P,TTINT
2624:         POP P,J
2625:         MOVE CHR,DEVIOS(DDB)
2626:         TLNN CHR,TTYIOW         ;DID THE LOSER TYPE SOMETHING TO US AT INTERUPT LEVEL?
2627:         JRST TWS2
2628: TWSYN1: PUSHJ P,WSYNC                   ;WAIT FOR INPUT
2629: TWS2:   MOVE IOS,[XWD TTYIOW+DDTM,IOACT]
2630:         ANDCAB IOS,DEVIOS(DDB)
2631:         POPJ P,
2632: 
    TTYSER page# 0044 next  prev
2634: ;MONUSR
2635: ;ROUTINE TO MOVE A LINE OR STRING FROM TTY INPUT BUFFER TO USER'S INPUT BUFFER
2636: ;CALLED ONLY FROM UUO LEVEL,FROM INPUT UUO ONLY
2637: 
2638: MONUSR: HRRZ    TAC,DEVIAD(DDB)         ;ADDRESS OF BUFFER IN USER AREA
2639:         PUSHJ   P,BUFCLR                ;CLEAR WHOLE BUFFER
2640:         JRST    ADRERR                  ;ADDRESS CHECK RETURN
2641:         PUSHJ   P,STLNAC                ;SETUP LINE
2642:         MOVEI   AC2,TTICHR              ;MAX NR OF CHARACTERS
2643:         HRRZ    AC1,DEVIAD(DDB)         ;ADRESS OF USR BUFFER-1
2644:         ADD     AC1,[XWD 10700,1]       ;MAKE BYTE POINTER POINT RIGHT
2645:         MOVEI   DAT,TTIBUF(DDB)         ;SPECIFY USER MODE INPUT BUFFER
2646: 
2647: MONUS1: PUSHJ   P,GETCHY                ;GET A CHAR. FROM IT
2648:         LDB     TAC,[POINT 7,CHR,35]    ;NO CTRL BITS
2649:         MOVE    TAC,SPCTAB(TAC)         ;GET GOOD BITS
2650:         JUMPE   CHR,MONUS3              ;ZERO IMPLIES EMPTY BFR
2651:         CAIE    CHR,3B28!12             ;↑Z? (END OF FILE FOR TTY).
2652:         JRST    MONUS9
2653:         MOVSI   IOS,IOEND       ;YES, SIGNIFY SO
2654:         IORB    IOS,DEVIOS(DDB)
2655:         JRST    MONUS3
2656: 
2657: MONUS9: XCTR    XDB,[IDPB CHR,AC1]      ;PLACE CHAR. IN USER BUFFER
2658:         TLNN    TAC,FCSBRK!BREAKB       ;IS IT A SYNC CHAR. ?
2659: MONUS2: SOJG    AC2,MONUS1              ;NO, USER BUFFER FULL?
2660:         CAIN    CHR,600                 ;STORED CONTROL C?
2661:         JRST    MONUS7                  ;YES, HANDLE IT
2662: 
2663: MONUS3: HRRZ    AC2,DEVIAD(DDB)         ;BREAK CHAR OR COUNTED OUT, INPUT UUO DONE
2664:         SUBI    AC1,1(AC2)              ;CALCULATE NUMBER OF WORDS
2665:         XCTR    XRW,[HRRM AC1,1(AC2)]   ;STORE IN 3RD BUFFER WORD
2666: 
2667: MONUS4: PUSHJ   P,ADVBFF                ;INPUT UUO DONE,NEXT BUFFER FULL?
2668:         JRST    MONUS5                  ;YES, INPUT REALLY IS DONE
2669:         JUMPG   AC2,MONUS5              ;IF WE GAVE HIM A WHOLE LINE THEN WE ARE DONE.
2670:         SKIPLE  TISYNC(DDB)             ;NO, DO WE HAVE MORE LINES FOR IT?
2671:         JRST    MONUS8                  ;YES, GIVE USER NEXT LINE, TOO
2672: 
2673: MONUS5: MOVSI   IOS,IOFST
2674:         IORB    IOS,DEVIOS(DDB)
2675:         TLZE    IOS,TTYIOW              ;TTY IN INPUT WAIT?
2676:         PUSHJ   P,SETIOD                ;YES, TAKE IT OUT OF IT
2677:         POPJ    P,0
2678: 
2679: MONUS6: PUSHJ   P,CNCMOD                ;CONTROL C MODE
2680:         MOVSI   TAC,110000              ;DECREMENT TAKR POINTER
2681:         ADDM    TAC,TITAKR(DDB)         ;SO NEXT ILDB WILL GET ↑C
2682:         AOS     TITCTR(DDB)             ;ADJUST COUNTER
2683:         SOS     TIFCTR(DDB)             ;ADJUST FREE CHAR. COUNT
2684:         PUSHJ   P,SYNCHK                ;FIX UP ACTIVATED COUNT
2685:         PUSHJ   P,COMSET                ;WAKE UP COMMAND DECODER
2686:         JRST    WSYNC                   ;AND WAIT FOR INTERPRETATION
2687: 
2688: MONUS7: MOVE    CHR,DEVMOD(DDB)
2689:         TLNN    CHR,TTYATC
2690:         TRNN    CHR,ASSCON!ASSPRG       ;THESE LOSERS CAN'T TYPE COMMANDS
2691:         CAIA
2692:         JRST    MONUS3                  ;SEND IT IN TO HIM
2693:         MOVE    IOS,[XWD TTYIOW,IOACT]
2694:         IORB    IOS,DEVIOS(DDB)         ;PUT JOB BACK IN IOWAIT
2695:         PUSHJ   P,MONUS6
2696:         JRST    TTYIN                   ;RESTART INPUT UUO
2697: 
2698: MONUS8: TLNN    IOS,IOEND               ;ROOM FOR ANOTHER BUFFER. ↑Z SEEN?
2699:         JRST    MONUSR                  ;NO. GO PASS ANOTHER LINE
2700:         POPJ    P,                      ;YES. LET UUOCON HANDLE EOF
    TTYSER page# 0045 next  prev
2702: ;TTYOUT
2703: ;OUTPUT UUO
2704: 
2705: TTYOUT: MOVSI   IOS,IOBEG
2706:         TDNE    IOS,DEVIOS(DDB)
2707:         TRO     IOS,IOSUPR              ;KILL ↑O ON FIRST OUTPUT
2708:         IOR     IOS,[XWD DDTM,MERTPO!MERTP1!IOACT]
2709:         ANDCAM  IOS,DEVIOS(DDB)
2710:         MOVSI   IOS,IO+IOFST
2711:         IORB    IOS,DEVIOS(DDB)
2712: 
2713: 
2714:         TLNN    IOS,TTYDTC
2715:         PUSHJ   P,STLNAC                ;GET LINE CHARACTERISTICS
2716:         PUSH    P,LINE          ;SAVE INFO
2717:         TDNN    IOS,[XWD TTYDTC,IOSUPR] ;CONTROL O?
2718:         PUSHJ   P,USRMON                ;NO, MOVE USER'S BUFFER TO TTO BUFFER
2719:         PUSHJ   P,ADVBFE                ;ADVANCE USER'S HEADERS
2720:         SKIPA
2721:         TDZA IOS,IOS            ;MORE BUFFERS. DON'T CLEAR IOACT.
2722:         MOVEI   IOS,IOACT               ;NO MORE BUFFERS
2723:         ANDCAB  IOS,DEVIOS(DDB)         ;CLEAR ACTIVE IN IOS
2724:         POP     P,LINE          ;RESTORE LINE INFO
2725:         PUSHJ P,TYPGO           ;GO START OUTPUT, IF NECESSARY.
2726:         TRNE IOS,IOACT          ;ARE WE DONE ?
2727:         JRST TTYOUT             ;NO. DO SOME MORE. 
2728:         POPJ P,
2729: 
    TTYSER page# 0046 next  prev
2731: ;USRMON
2732: ;ROUTINE TO MOVE USER OUTPUT BUFFER TO MON. OUTPUT BUFFER
2733: ;CALLED ONLY AT UUO LEVEL,BY OUTPUT UUO
2734: 
2735: USRMON: HRRZ    AC2,DEVOAD(DDB)         ;ADDRESS OF 2ND BUFFER WORD
2736:         XCTR    XR,[HRRZ AC2,1(AC2)]    ;NUMBER OF WORDS TO OUTPUT
2737:         IMULI   AC2,5                   ;NR OF CHARACTERS
2738: 
2739: USRMN1: HRRZ    AC1,DEVOAD(DDB)         ;ADDRESS OF BUFFER
2740:         ADD     AC1,[XWD 10700,1]       ;MAKE POINTER.
2741: 
2742: USRMN2: XCTR    XLB,[ILDB CHR,AC1]      ;PICK UP CHARACTER
2743: USRMN4: JUMPE   CHR,USRMN5              ;IF NULL, IGNORE
2744:         PUSHJ   P,OUTCHR                ;PLACE IN OUTPUT BUFFER
2745:         JUMPE   CHR,USRMN3              ;IF NO MORE ROOM IN MON. BUFFER
2746: 
2747: USRMN5: SOJG    AC2,USRMN2              ;LOOP AS LONG AS THERE ARE CHAR'S.
2748:         DPB     AC2,PFITCH              ;NO CHARACTERS TO FIT
2749:         POPJ    P,                      ;DONE
2750: 
2751: USRMN3: PUSH    P,AC2
2752:         CAILE   AC2,777                 ;GREATER THAN MAX? (9 BIT FIELD)
2753:         MOVEI   AC2,777                 ;YES, USE MAX
2754:         DPB     AC2,PFITCH              ;NUMBER OF CHARACTERS TO GO
2755:         PUSH    P,AC1                   ;SAVE RELOCATABLE POINTER
2756:         MOVE    LINE,-3(P)              ;GET SAVED LINE CHAR WORD
2757:         PUSHJ   P,TTOUWS                ;WAIT FOR IO
2758:         POP     P,AC1                   ;RESTORE POINTER
2759:         POP     P,AC2                   ;GET BACK CHR COUNT
2760:         MOVE    IOS,DEVIOS(DDB)         ;RESTORE IOS
2761:         XCTR    XLB,[LDB CHR,AC1]       ;GET LAST CHARACTER
2762:         TRNN    IOS,IOSUPR              ;USER TYPED ↑O?
2763:         JRST    USRMN4                  ;RETURN TO OUT LOOP
2764:         POPJ    P,                      ;YES, CONSIDER BUFFER MOVED
2765: 
2766: TTOUWS: MOVEI   IOS,IOACT       ;SET DEVICE ACTIVE (TTY)
2767:         IORB    IOS,DEVIOS(DDB)
2768:         PUSHJ   P,TYPGO         ;START TYPING IF NEEDED
2769:         JRST    WSYNC                   ;WAIT TILL ROOM IN BUFFER
    TTYSER page# 0047 next  prev
2771: ;SCNIN1, SCNTYP, KBDINT
2772: ;COMMON PARTS OF CTY AND SCANNER INTERRUPT SERVICE ROUTINES.
2773: 
2774: 
2775: SCNIN1:
2776:         DATAI   DCSA,LINE       ;GET LINE NO. FROM FULL DUPLEX.
2777:         CONO    DCSA,4000+FSNCHN
2778:                                 ; RELEASE XMITTER SCANNER
2779:         JRST    XMTINT          ;IN SCNSER OR TTYSER
2780: ;ROUTINE TO OUTPUT A CHARACTER ON A LINE
2781: ;CALLED FROM TYP OR TYPL IN SCNSER
2782: 
2783: SCNTYP: CONO PI,SCNOFF          ;TURN SCANNER PI OFF IN CASE AT USER LEVEL
2784:                                 ;SO NO INTERRUPTS BETWEEN CONO, AND DATAO
2785:         CONO DCSB,(LINE)        ;NO
2786:         DATAO DCSA,CHR
2787:         CONO PI,SCNON           ;TURN SCANNER PI BACK ON
2788:         SKIPE   DDB
2789:         DPB CHR,PLASTC  ;SAVE CHAR FOR FULL DUPLEX
2790:         POPJ P,
2791: 
2792: 
2793: IFN FTOIKB,     {
2794: KBDINT:
2795:         JSR SCNSAV              ; SAVE AC'S, SET UP P
2796:         DATAI KBD,CHR
2797:         LDB LINE,[POINT 4,CHR,17]
2798:         LDB UCHN,[POINT 2,CHR,9]        ;GET CONTROL BITS.
2799:         TLZ CHR,777577
2800:         CAIN CHR,2      ;CHECK FOR LOST CHR
2801:         POPJ P,
2802:         ADDI LINE,DPYL0
2803:         CAIN CHR,1      ;USE BLANK KEY FOR ALTMODE
2804:         MOVEI CHR,174
2805:         CAIN CHR,177    ;IS IT A BACKSPACE ?
2806:         MOVEI CHR,136   ;YES. PRETEND HARDWARE CODE IS 136.
2807:         HRRZ DSER,CHR           ;PRESERVE UNSHIFTED CHAR.
2808:         TLZE CHR,200
2809:         HRRZ CHR,SHFTBL(CHR)
2810:         HRRZ CHR,CONVTB(CHR)
2811:         CAIE CHR,600
2812:         DPB UCHN,[POINT 2,CHR,28]       ;PUT IN THE CTRL. BITS.
2813: KBDIN1: CAIN CHR,213                    ;<CTRL1>VT?
2814:         MOVEI CHR,10042
2815:         CAIN CHR,212                    ;<CTRL1>LF?
2816:         MOVEI CHR,10044
2817:         CAIN CHR,412                    ;<CTRL2>LF?
2818:         MOVEI CHR,10000                 ;PATCH FOR ↑O
2819:         JRST RECINA
2820: 
    TTYSER page# 0048 next  prev
2822: ;SHFTBL, CONVTB
2823: SHFTBL: 0174002217700
2824:         0111213141500
2825:         0200000240
2826:         3200000023
2827:         401000000
2828:         173175017677254617
2829:         2367104452100
2830:         4247331343436350
2831:         REPEAT 30,<0>   ;100-127
2832:         00031162713643
2833:         45                      ;140
2834: XXZ←←101
2835:         REPEAT 32,<XXZ
2836: XXZ←←XXZ+1>
2837:         017400136
2838: 
2839: CONVTB:        XWD 0,600
2840:         XXZ←←1
2841:         REPEAT 27,<XWD XXZ,XXZ
2842:         XXZ←←XXZ+1>
2843:         XWD 137,137
2844:         XWD 31,31
2845:         XWD 134,136
2846:         XXZ←←33
2847:         REPEAT 45,<XWD XXZ,XXZ
2848:         XXZ←←XXZ+1>
2849:         XWD 140,140
2850:         XXZ←←101
2851:         REPEAT 33,<XWD XXZ,XXZ
2852:         XXZ←←XXZ+1>
2853:         XWD 177,32      ;134
2854:         XWD 135,135
2855:         XWD 32,177      ;136 IS HARDWARE FORM OF DELETE THESE DAYS.
2856:         XWD 30,30
2857:         XWD 100,100
2858:         XXZ←←141
2859:         REPEAT 33,<XWD XXZ,XXZ
2860:         XXZ←←XXZ+1>
2861:         XWD 176,175     ;174 IS HARDWARE ALTMODE.
2862:         XWD 174,176     ; 
2863:         XWD 175,174
2864:         XWD 136,134             }
    TTYSER page# 0049 next  prev
2866: ;DKBINT
2867: 
2868: DKBINT:MOVEM   CHR,DKBCHR      ;SAVE ONE AC WHILE WE THINK ABOUT THIS CHAR
2869:         DATAI   DKB,CHR
2870:         TRNE    CHR,1B23        ;INVALID?
2871:         TRNE    CHR,1B22        ;SPW?
2872:         JRST    DKBLUZ          ;IGNORE
2873:         EXCH    CHR,DKBCHR      ;STORE CHARACTER WHERE WE'LL SEE IT LATER
2874:         JSR     SCNSAV
2875: IFN FTHG,       <       PUSHJ P,HG      >
2876:         DATAI   CHR
2877:         JUMPGE  CHR,.+2
2878:         DATAO   PI,DKBCHR       ;DISPLAY IN LIGHTS IF DATA SWITCH 0 SET
2879:         MOVE    CHR,DKBCHR      ;GET BACK CHAR
2880:         HLRZ    LINE,CHR
2881:         ANDI    CHR,1777        ;MASK UNWANTED BITS
2882:         CAIL LINE,DPYNUM+DDNUM
2883:         POPJ P,
2884:         ADDI LINE,DPYL0
2885:         TRC     CHR,1700                ;MAKE SENSE OF THESE BITS RIGHT
2886:         MOVEI AC2,(CHR)
2887:         LDB     TAC,[POINT 2,CHR,29]    ;SHIFT-TOP
2888:         LDB     UCHN,[POINT 2,CHR,27]   ;CTRL-META
2889:         ANDI    CHR,77                  ;JUST THESE FOR INDEX
2890:         CAIE    CHR,41                  ;BREAK?
2891:         CAIN    CHR,42                  ;ESCAPE?
2892:         JRST    DKBSPC                  ;SPECIAL CHARACTER
2893:         CAIN    CHR,44                  ;CLEAR?
2894:         JRST    DKBSPC
2895:         LDB     DAT,DKBBYT(TAC)
2896:         ANDCMI  TAC,1                   ;TOP ONLY
2897:         LDB     DSER,DKBBYT(TAC)        ;UNSHIFTED CHAR.
2898:         MOVEI   CHR,(DAT)               ;GET BACK SAVED CHAR.
2899:         CAIE    CHR,600                 ;EXCEPT FOR ↑C
2900:         DPB     UCHN,[POINT 2,CHR,28]   ;GET BACK CONTROL BITS
2901:         TRZA    DSER,600                ;NO CONTROL BITS HERE
2902: DKBSPC: TRO     CHR,10000               ;MAKE IT SPECIAL
2903:         JRST    RECINA
2904: 
2905: DKBLUZ: EXCH    CHR,DKBCHR      ;RESTORE CHR, LEAVE CHARACTER WHERE WE CAN SEE IT
2906:         DATAO   PI,DKBCHR       ;DISPLAY LOSING LINE NUMBER (AND CHAR) IN LITES
2907:         JRST    12,@CH5         ;DISMISS INTERRUPT
2908: 
2909: 
2910: DKBBYT: POINT 9,DKBTBL(CHR),8
2911:         POINT 9,DKBTBL(CHR),17
2912:         POINT 9,DKBTBL(CHR),26
2913:         POINT 9,DKBTBL(CHR),35
    TTYSER page# 0050 next  prev
2915: ;DKBTBL
2916: DEFINE DKBCHR(A,B)<
2917: BYTE(9)<"A">+40,<"A">,<"B">,<"B">
2918: >
2919: 
2920: 
2921: ;FORMAT IS   BYTE(9)CHAR        SHIFT CHAR      TOP CHAR        TOP SHIFT CHAR
2922: 
2923: DKBTBL: 0
2924:         DKBCHR  A,
2925:         DKBCHR  B,π
2926:         DKBCHR  C,ε
2927:         BYTE(9) "d","D",74,74
2928:         BYTE(9) "e","E",100,100
2929:         BYTE(9) "f","F",76,76
2930:         DKBCHR  G,
2931:         DKBCHR  H,=
2932:         DKBCHR  I,'
2933:         BYTE(9) "j","J",137,137
2934:         DKBCHR  K,<>
2935:         DKBCHR  L,<>
2936:         DKBCHR  M,
2937:         DKBCHR  N,
2938:         BYTE(9) "o","O",173,173
2939:         BYTE(9) "p","P",176,176
2940:         DKBCHR  Q,
2941:         DKBCHR  R,#
2942:         DKBCHR  S,
2943:         DKBCHR  T,&
2944:         BYTE(9) "u","U",140,140
2945:         DKBCHR  V,λ
2946:         DKBCHR  W,
2947:         DKBCHR  X,β
2948:         BYTE(9) <"y">,<"Y">,42,42
2949:         DKBCHR  Z,α
2950: 
2951: DEFINE DKBCHR(A,B)<
2952: BYTE(9)<"A">,<"A">,<"B">,<"B">
2953: >
2954: 
2955:         BYTE(9) 15,15,15,15
2956:         DKBCHR  <\>,
2957:         BYTE(9) 12,12,12,12
2958:         0                                       ;36
2959:         0                                       ;37 FUCK
2960:         BYTE(9) 40,40,40,40                     ;40
2961:         0                                       ;41 BREAK
2962:         0                                       ;42 ESC
2963:         BYTE(9) 600,600,600,600                 ;43 ↑C
2964:         0                                       ;44 CLEAR
2965:         BYTE(9) 11,11,11,11
2966:         BYTE(9) 14,14,14,14
2967:         BYTE(9) 13,13,13,13
2968:         DKBCHR  <(>,[
2969:         DKBCHR  <)>,<]>
2970:         DKBCHR  *,
2971:         DKBCHR  +,|
2972:         DKBCHR  <,>,!
2973:         DKBCHR  -,¬
2974:         DKBCHR  .,?
2975:         DKBCHR  /,
2976:         DKBCHR  0,0
2977:         DKBCHR  1,
2978:         DKBCHR  2,
2979:         DKBCHR  3,
2980:         DKBCHR  4,
2981:         DKBCHR  5,
2982:         DKBCHR  6,$
2983:         DKBCHR  7,%
2984:         BYTE(9) <"8">,<"8">,32,32
2985:         BYTE(9) <"9">,<"9">,30,30
2986:         DKBCHR  :,
2987:         DKBCHR  <;>,↑
2988:         BYTE(9) 177,177,177,177
2989:         BYTE(9) 175,175,175,175
2990:         0
2991:         0
    TTYSER page# 0051 next  prev
2993: ;SCNINT
2994: ;SCANNER INTERRUPT SERVICE ROUTINE.
2995: 
2996: SCNINT:
2997:         JSR     SCNSAV
2998:         CONSO   DCSA,10         ;RECEIVER FLAG?
2999:         JRST    SCNIN1          ;NO,XMITTER FLAG
3000:         CONI    DCSB,LINE       ;SCANNER INPUT.
3001:         DATAI   DCSB, CHR
3002:         CAIL    LINE,SCNNUM     ;ARE WE ENABLED FOR THIS LINE NUMBER?
3003:         POPJ    P,              ;NO, DISMISS INTERRUPT
3004:         CAIN LINE,APLINE
3005:         LSH CHR,-2              ;PUT AP STUFF IN RIGHT PLACE
3006:         JRST    RECINT          ;RECEIVER INT. HANDLER
    TTYSER page# 0052 next  prev
3008: ;CTYINT
3009: ;CTY INTERRUPT SERVICE ROUTINE
3010: 
3011: CTYINT:
3012:         JSR     SCNSAV                  ;YES, SAVE AC'S
3013:         MOVEI   LINE,TCONLN             ;LOAD LINE WITH PROPER
3014:         CONSO   TTY,40                  ;YES. TTI FLAG?
3015:         JRST    CTYOU1                  ;NO.
3016:         DATAI   TTY,CHR
3017: IFE 0,<
3018:         JRST    RECINT                  ;RECEIVER INTERRUPT HANDLER
3019: >
3020: IFN 0,<
3021:         MOVEI   LINE,26
3022:         ANDI    CHR,177
3023:         CAIN    CHR,1
3024:         JRST    CTYFOO
3025:         MOVE    UCHN,CTYFO1#
3026:         SETZM   CTYFO1
3027:         MOVE    DSER,CHR
3028:         DPB     UCHN,[POINT 2,CHR,28]
3029:         JRST    KBDIN1
3030: 
3031: CTYFOO: AOS     CTYFO1
3032:         POPJ    P,
3033: >
3034: 
3035: CTYOU1: CONO    TTY,200+SCNCHN          ; CLEAR TTO FLAG
3036:         JRST    XMTINT                  ;COMMON TRANSMIT INTERRUPT HANDLER
3037: 
3038: ;SCANNER INTERRUPT SERVICE ROUTINE IS IN SEPARATE DEVICE DEPENDENT SECTION
3039: 
    TTYSER page# 0053 next  prev
3041: ;RECINT, RECINA, RECINB, RECINC, RECIM3, NOESC, ESCRET
3042: 
3043: ;COMMON RECEIVER INTERRUPT FOR ALL KEYBOARD DEVICES
3044: 
3045: RECINT:
3046:         MOVEI UCHN,0    ;NO CONTROL BITS FROM MOST KEYBOARDS.
3047: RECINA: HLL LINE,LINTAB(LINE)
3048:         MOVE TAC,LINTAB(LINE)           ;TTYLOK TEST WAS HERE (SEE BELOW) (ME+BH)
3049: PTYREC: JUMPE CHR,CPOPJ         ;PTY output routines enter here (at uuo level).
3050:         TRNE CHR,10000
3051:         JRST SETESC
3052: NOESC:  TRNE TAC,REGESC+SPCESC
3053:         JRST DOESC
3054: 
3055: ESCRET: HLL     LINE,LINTAB(LINE)       ;TTYLOK TEST MOVED DOWN TO ALLOW SOME ESCS
3056:         TLNN    LINE,CTYLIN             ;ALWAYS LET CTY BY
3057:         SKIPN   TTYLOK                  ;ARE WE IN LOCKOUT MODE
3058:         JRST    NOLOCK                  ;NO
3059:         MOVSI   DDB,400000              ;MAKE A TEST BIT
3060:         MOVNI   LINE,(LINE)
3061:         LSH     DDB,(LINE)
3062:         DATAI   APR,LINE                ;READ CONSOLE SWITCHES
3063:         TDNN    DDB,LINE                ;DOES THIS GUY GET BY?
3064:         POPJ    P,                      ;NO
3065: NOLOCK: LDB     LINE,[PUNITS6,,TAC]
3066:         SKIPE   DDB,TTYTAB(LINE)        ;IS THERE A DDB FOR THIS LINE?
3067:         JRST    RECIN1                  ;YES, GO ON
3068:         CAIE    LINE,IMSSS
3069:         CAIN    LINE,APLINE             ;FLUSH AP LINE OR IMSSS IF NO DDB
3070:         POPJ    P,
3071:         PUSH    P,AC1
3072:         PUSHJ   P,DDBSRC                ;NO, FIND ONE
3073:         JRST    TYPX
3074:         POP     P,AC1
3075: RECIN1: HLL     LINE,LINTAB(LINE)
3076: RECIN8:
3077: IFN FTTALK,<    CAIN    CHR,10044       ;DID HE TYPE CLEAR?
3078:                 JRST    RECINZ          ;YES, LET POOR FELLOW FLUSH HIS LINED
3079:                 TLNE    LINE,TLKRNG     ;IN A TALK RING?
3080:                 JRST    DOTALK          ;YES, GO TALK
3081: RECINZ:
3082: >
3083:         MOVE    IOS,DEVIOS(DDB)         ;SET UP IOS
3084:         TLNE    LINE,DDDLIN!DISLIN
3085:         JRST    KBDED           ; IF A DPY, GO TO SMART EDITOR
3086: RECIN2: TLNE    LINE,IMLIN      ;IMLAC LINE?
3087:         JRST    RECIML          ;YES, SPECIAL INTERRUPT RECEIVER FOR IMLACS
3088: RECIM2: ANDI    CHR,177         ;7-BIT ASCII ONLY
3089: ;*** BEGIN RPH HACK TO RUN DATAPHONES AS DATA DEVICES
3090:         TLNE    IOS,TPMON       ;MONITOR HEAL THY SELF
3091:         JRST    NOSPMD          ;NO SPECIAL MODE (IN CASE THIS IS HIS CONSOLE)
3092:         LDB     TAC,PIOMOD      ;PICK UP IO MODE
3093:         CAIE    TAC,10          ;SPECIAL "IMAGE" MODE?
3094:         CAIN    TAC,11          ;ANOTHER SPECIAL MODE FOR AP WIRE
3095:         JRST [  TLZ     IOS,IMLTTY      ;**BO MOD TO TURN OFF IMLAC CONTROL FLAG**
3096:                 TLNE    IOS,TTYHLD
3097:                 PUSHJ   P,TTYUNH        ;ALSO DON'T ALLOW HOLDING.
3098:                 MOVEI   DAT,TTIBUF(DDB)
3099:                 PUSHJ   P,PUTCHI        ;PUT CHARACTER DIRECTLY INTO INPUT BUFFER
3100:                 JFCL                    ;IGNORE FAILURE
3101:                 MOVE    DAT,FCTR(DAT)
3102:                 CAIE    TAC,10          ;INTERRUPT EVERY CHAR?
3103:                 CAIG    DAT,TTICHR/2    ;NO, HALF FULL YET?
3104:                 TLOA    IOS,DDTM        ;YES, ACTIVATE IT NOW
3105:                 JRST    SNKTST          ;DON'T ACTIVATE YET
3106:                 JRST    RECIN4]         ;ACTIVATE, BUT NOT COMMAND DECODER
3107: NOSPMD:
3108: ;*** END RPH HACK
3109:         CAIE CHR,0
3110: RECINC: CAIN    CHR,3                   ;CONTROL C?
3111: RECINB: PUSHJ   P,CNCTST                ;YES, SEE IF 2ND CONTROL C
3112:         TLNE LINE,IMLIN
3113:         JRST RECIM3             ;IMLAC'S SEND ALL THE RIGHT CODES.
3114:         TLNN LINE,PTYLIN        ;PTY'S WILL BE SENDING RIGHT CURLY BRACKET
3115:         CAIE CHR,176
3116:         CAIN CHR,33             ;CONVERT OLD LOSING ALTMODES INTO NEW.
3117:         MOVEI CHR,175
3118: RECIM3: LDB     HPOS,PHPOS              ;PICK UP HORIZONTAL POSITION OF OUTPUT CHAR.
3119:         MOVEI   DAT,TTIBUF(DDB)         ;USER MODE INPUT BUFFER
3120:         PUSHJ   P,TTEDIT                ;GO EDIT (AND ECHO) CHARACTER
3121:         TLNN    IOS,TPMON               ;NOT IN MONITOR MODE
3122:         TLNN    LINE,PTYLIN
3123:         JRST    RECIN5                  ;ONLY SPECIAL CHECK FOR PTYS
3124:         JUMPE   UCHN,RECIN5
3125:         MOVE    TAC,ACTMOD(DDB)
3126:         TRNE    TAC,SUPSCM
3127:         CAIE    UCHN,3
3128:         TRNN    TAC,SUPBTS
3129:         TLO     IOS,SYNC                ;ACTIVATE PTY ON CTRL META
3130: RECIN5: TRNN    IOS,NOECHO              ;IF WE ECHOED IT,
3131:         DPB     HPOS,PHPOS              ;STORE HORIZONTAL POSITION
3132:         TLNE    IOS,TTYHLD              ;IF TYPEOUT IS HOLDING
3133:         CAMN    TAC,SPCTAB+2            ;AND THE CHAR WASN'T ↑B...
3134:         CAIA
3135:         PUSHJ   P,TTYUNH                ;THEN UNHOLD.
3136:         HLLM    LINE,LINTAB(LINE)       ;UPDATE LINE TABLE
3137:         MOVE    TAC,TIFCTR(DDB)         ;FREE SPACES LEFT
3138:         CAIG    TAC,12                  ;ONLY 10 LEFT?
3139:         JRST    RWARN                   ;YES. GO OUTPUT XOFF
3140:         TLNN    IOS,SYNC!DDTM           ;WAS A BREAK CHARACTER TYPED?
3141:         JRST    SNKTST                  ;NO, GO SEE IF ECHO NEED BE TYPED
3142:         TLNN    IOS,SYNC                ;DON'T CRANK UP CH7 UNLESS SYNC CHAR.
3143:         JRST    RECIN4
    TTYSER page# 0054 next  prev
3145: ;RECIN3, RECIN4, UTYPET, TYPTST, TYPGO, TTINT
3146: 
3147: RECIN3: MOVSI   TAC,COMBIT              ;IS IT IN COMMAND WAIT NOW?
3148:         TDNN    TAC,TTYTAB(LINE)        ;..
3149:         PUSHJ   P,COMSET                ;NO, WAKE UP COMMAND DECODER NOW
3150: RECIN4: MOVEI   DAT,TTIBUF(DDB)         ;SET FOR SYNCHA
3151:         TLZE    IOS,SYNC!DDTM           ;ACTIVATION CHAR.?
3152:         PUSHJ   P,SYNCHA                ;UPDATE ACTIVATED CHAR. COUNT
3153:                                         ;CLEAR SYNC IN CORE
3154:         MOVEM   IOS,DEVIOS(DDB)         ; ..
3155:         MOVE    TAC,TIPCTR(DDB)         ;UPDATE COUNTER FOR ↑U
3156:         DPB     TAC,PLSTLC
3157:         TLNE    IOS,TPMON               ;NO INTERRUPTS IN MONITOR MODE.
3158:         JRST    TYPTST
3159:         LDB     J,PJOBN                 ; PICK UP JOB NUMBER
3160:         MOVSI   AC1,INTTTY              ; GIVE HIM A TTY INTERRUPT IF DESIRED
3161:         TDNE    AC1,JBTIEN(J)           ; IS HE ENABLED FOR IT?
3162:         PUSHJ   P,TTINT                 ; YES, DO IT.
3163:         TLZN    IOS,TTYIOW              ;IN TELETYPE INPUT WAIT?
3164:         JRST    TYPTST                  ;NO, GO ECHO
3165: SNKWAK: PUSHJ   P,STTIOD                ;YES, SET IO DONE(OUT OF TTY IOW)
3166:         PUSHJ   P,STXTIM                ;UPDATE INTERACTION RUN TIME (XTIME)
3167:         MOVSI   IOS,IOW!TTYIOW!SNKWAT
3168:         ANDCAB  IOS,DEVIOS(DDB)         ;CLEAR WAIT BITS
3169: UTYPET:
3170: TYPTST: TLNE    IOS,TTYDTC
3171:         JRST    TYPT1
3172:         PUSHJ   P,STLNAC                ;CLOBBERED BY STTIOD
3173:         TLNE LINE,PTYLIN                ;IS THIS A PTY
3174:         JRST PTOCK                      ;YES, JUST GO CHECK PTY STUFF
3175:         MOVSI   IOS,TOIP
3176:         CONO    PI,SCNOFF
3177:         TDNE    IOS,DEVIOS(DDB)         ;TYPE OUT HAPPENNING?
3178:         JRST    TYPT1
3179:         IORB    IOS,DEVIOS(DDB)         ;NO, BUT THERE IS NOW
3180:         CONO    PI,SCNON
3181:         TLNN IOS,TTYDTC         ;DON'T TYPE IF HE'S DETACHED...
3182:         JRST    XMTIN1                  ;START OUTPUT
3183: TYPT1:  CONO    PI,SCNON
3184:         POPJ    P,
3185: 
3186: SNKTST: TLNN IOS,SNKWAT                 ;IS LOSER IN SNEAK WAIT?
3187:         JRST TYPTST                     ;NO, PROCEED NORMALLY
3188:         JRST SNKWAK
3189: 
3190: TYPGO: MOVE    IOS,DEVIOS(DDB)
3191:         TDNE    IOS,[XWD TTYDTC,IOSUPR]
3192:         JRST    TYPT1                   ;FLUSH OUTPUT
3193:         PUSHJ P,STLNAC
3194:         MOVSI   IOS,IO
3195:         TLNN LINE,PTYLIN
3196:         CONO    PI,SCNOFF               ;MAKE SURE OF NO RACE!
3197:         IORB    IOS,DEVIOS(DDB)
3198:         JRST    TYPTST
3199: 
3200: RWARN:  TLO     IOS,DDTM                ;ACTIVATE EVERYTHING SO FAR
3201:         TLNE    LINE,FULTWX!PTYLIN!DISLIN!IMLIN ;CAN LINE BE STOPPED?
3202:         JRST    RECIN3                  ;NO. WAKE JOB AND CROSS FINGERS.
3203:         MOVEI   CHR,23                  ;YES. SEND AN XOFF.
3204:         PUSHJ   P,PUTCHO                ; ..
3205:         MOVEI   CHR,IDLECH              ;AND AN IDLE FOR TTY TO THINK ON.
3206:         PUSHJ   P,PUTCHO                ;OUTPUT IT.
3207:         JRST    RECIN3                  ;GO WAKE JOB.
3208: 
3209: TTINT:  IORM AC1,JBTIRQ(J)
3210:         SETOM INTREQ(PID)
3211:         HLLOS CLKFLG(PID)
3212:         CONO PI,1B24!1(7-CLKCHN)
3213:         POPJ P,
3214: 
3215: STXTIM: LDB     J,PJOBN                 ;GET JOB NUMBER
3216: STXTM2:                                ;ENTRY POINT FROM RUN-JOB CODE
3217:         JUMPE   J,CPOPJ                 ;IF NO JOB, NO XTIME
3218:         SKIPGE  XTIME(J)                ;IS NO-UPDATE BIT ON?
3219:         POPJ    P,                      ;YES.  DONT DO ANYTHING!
3220:         MOVE    TAC,TTIME(J)            ;PICK UP CURRENT RUN TIME
3221:         MOVEM   TAC,XTIME(J)            ;UPDATE INTERACTION RUN TIME
3222:         SKIPGE  TAC,JBTWAT(J)           ;PICK UP WAIT TIME
3223:         ADD     TAC,UPTIME              ;MAKE IT HONEST
3224:         MOVEM   TAC,JB2WAT(J)           ;AND SAVE IT
3225:         HRLS    DSKOPS(J)               ;SAVE CURRENT NUMBER OF DISK OPERATIONS
3226:         POPJ    P,
    TTYSER page# 0055 next  prev
3228: ;ESCAPE BITS
3229: ;DEFINITIONS FOR ESCAPE PROCESSOR
3230: ;ALL THIS STUFF GOES IN RH(LINTAB)
3231: 
3232: REGESC←←400000  ;NORMAL ESCAPE TYPED
3233: SPCESC←←200000  ;SPECIAL
3234: ESCNEG←←100000  ;NEGATION FLAG (BREAK, ETC.)
3235: 
3236: ESCTYP←←200200                  ;BYTE PNTR FOR TYPE BITS
3237: ESCARG←←PUNITS14+<17-PUNITS>6 ;EVERYTHING ELSE IS ARG
3238: ESCFLD←←PUNITS14+<22-PUNITS>6 ;WHOLE ESCAPE FLD
3239: ESCNUL←←ESCNEG-PUNITS-1                ;MAX VAL USED FOR NULL (ZERO SOMETIMES LEGAL)
3240: ESCMAX←←ESCNUL-1                ;MAX LEGAL VALUE
    TTYSER page# 0056 next  prev
3242: ;SETESC
3243: ;HERE ON <ESC>,<BREAK>, OR <CLEAR> (ALSO FUNNY CHARS FROM PTYS)
3244: ;ESCAPE CODE BITS ARE SET UP FOR NEXT TIME
3245: 
3246: SETESC: CAIN CHR,10044
3247:         JRST NOESC              ;<CLEAR> ISN'T REALLY AN ESC CHR
3248:         MOVEI AC3,
3249:         CAIN CHR,10042
3250:         MOVEI AC3,REGESC-PUNITS+ESCNUL
3251:         CAIN CHR,10041
3252:         JRST [  CAIE UCHN,1     ;WATCH OUT FOR CTRL-BRK
3253:                 MOVEI AC3,<REGESC+ESCNEG>-PUNITS+ESCNUL
3254:                 JRST .+1]
3255:         CAIN AC2,1641
3256:         MOVEI AC3,SPCESC-PUNITS+ESCNUL
3257:         DPB AC3,[ESCFLD,,LINTAB(LINE)]
3258:         JUMPN AC3,CPOPJ         ;EXIT IF ESC CHR
3259:         HLRE AC1,CHR
3260:         JUMPLE AC1,.+2
3261:         ANDI AC1,ESCNUL
3262:         JUMPN AC1,.+2
3263:         MOVEI AC1,ESCNUL        ;ELSE MAP 10XXX→<ESC>XXX, 14XXX→<BRK>XXX
3264:         TRNE CHR,4000           ;(EASIER FORM FOR PTYUUO'S)
3265:         MOVN AC1,AC1
3266: STDESC: CAIN DSER,"a"
3267:         JRST VDESCA
3268:         CAIN DSER,"d"
3269:         JRST VDESCD
3270:         CAIN DSER,"s"
3271:         JRST VDESCS
3272:         CAIN DSER,"t"
3273:         JRST VDESCT
3274:         CAIN DSER,"u"
3275:         JRST ASESC      ;AUDIO SWITCH CHANNEL SELECT
3276:         CAIN DSER,"b"
3277:         JRST ESCB       ;AUDIO SWITCH UNBEEPER
3278: STDES2: TRO CHR,10000   ;PASS IT ON TO LINED
3279:         CAIN AC1,ESCNUL ;WITH ARG IN SIGN-MAGNITUDE FORM
3280:         MOVEI AC1,
3281:         JUMPGE AC1,ESCRET
3282:         MOVN AC1,AC1
3283:         CAIN AC1,ESCNUL
3284:         MOVEI AC1,
3285:         HRLI AC1,400000
3286:         JRST ESCRET
3287: 
3288: ;REMEMBER THAT ARG WE READ IN IN DECIMAL? WELL, WE REALLY WANTED
3289: ;TO READ IT IN OCTAL, SEE, SO . . .
3290: 
3291: ESCOCS: AOS (P)
3292: ESCOCT: IDIVI AC1,=100
3293:         IDIVI AC2,=10
3294:         LSH AC2,3
3295:         ADD AC2,AC3
3296:         LSH AC1,6
3297:         ADD AC1,AC2
3298:         POPJ P,
    TTYSER page# 0057 next  prev
3300: ;DOESC
3301: ;HERE ON NEXT CHAR AFTER ESCAPE. ANY ARG IS ACCUMULATED LEAVING ESC BITS SET.
3302: ;OTHER CHARS CLEAR BITS (LEAVING ESCAPE MODE) AND DISPATCH TO APPROP HANDLER
3303: 
3304: DOESC:  LDB AC1,[ESCARG,,TAC]
3305:         LDB AC2,[ESCTYP,,TAC]
3306:         CAIE AC2,1
3307:         JRST .+3
3308:         CAIE UCHN,3
3309:         SOJA AC2,ESCXIT
3310:         CAIL DSER,"0"
3311:         CAILE DSER,"9"
3312:         JRST DOESC1
3313:         CAIN AC1,ESCNUL
3314:         TDZA AC1,AC1
3315:         IMULI AC1,12
3316:         ADDI AC1,-"0"(DSER)
3317:         CAILE AC1,ESCMAX
3318:         MOVEI AC1,ESCMAX
3319:         DPB AC1,[ESCARG,,LINTAB(LINE)]
3320:         POPJ P,
3321: 
3322: DOESC1: CAIN DSER,"-"
3323:         JRST DOESCN
3324:         TRNE TAC,ESCNEG
3325:         MOVN AC1,AC1
3326: ESCXIT: ANDI TAC,1PUNITS-1
3327:         HRRM TAC,LINTAB(LINE)
3328:         JRST @ESCDSP(AC2)       ;NOTE AC2>0 OR WE WOULDN'T BE HERE
3329: 
3330: ESCDSP: ESCRET
3331:         SPESC
3332:         STDESC
3333: 
3334: DOESCN: MOVEI TAC,ESCNEG
3335:         XORM TAC,LINTAB(LINE)
3336:         POPJ P,
    TTYSER page# 0058 next  prev
3338: ;SPESC
3339: SPESC:  TLO TAC,200000
3340: IFN FTDDT,<
3341:         CAIN CHR,600
3342:         CAIE UCHN,3
3343:         CAIA
3344:         JRST DDTCAL
3345: >;FTDDT
3346:         CAIE CHR,600-40(DSER)
3347:         JRST ESCRET
3348:         CAIN CHR,600+"L"
3349:         JRST SPESCL
3350:         CAIE CHR,600+"M"
3351:         JRST STDESC
3352:         PUSHJ P,ESCOCT
3353:         CAIL AC1,TTPLEN
3354:         MOVEI AC1,(LINE)
3355:         HRRM AC1,LINTAB(LINE)
3356:         POPJ P,
3357: 
3358: SPESCL: MOVE TAC,LINE
3359:         MOVE AC2,LINTAB(TAC)
3360:         TLNN AC2,DDDLIN
3361:         POPJ P,
3362:         SUBI TAC,DDL0
3363:         PUSHJ P,ESCOCT
3364:         CAIL AC1,DDL0
3365:         CAIL AC1,DDL0+DDNUM
3366:         POPJ P,
3367:         SKIPN AC2,LETAB-DPYL0(AC1)
3368:         SKIPA AC3,VDMAP-DDL0(AC1)
3369:         MOVE AC3,VDTMP(AC2)
3370:         PUSHJ P,VDSTR
3371:         MOVEM AC3,VDTMP(AC2)
3372:         JRST VDOUT
    TTYSER page# 0059 next  prev
3374: ;ESCAPES
3375: 
3376: ;ADD CHANNEL TO MAPPING
3377: VDESCA: PUSHJ P,VDESTV
3378:         PUSHJ P,VDECHK
3379:         PUSHJ P,VDVCHK
3380:         DPB AC1,[400,,VDTMP(AC2)]
3381:         PUSHJ P,VDSTRB
3382:         IORM AC3,VDTMP(AC2)
3383:         JRST VDOUT
3384: 
3385: ;NORMALIZE SWITCH FOR THIS CHANNEL
3386: VDESCN: PUSHJ P,VDNORM
3387:         JRST VDOUT
3388: 
3389: ;DELETE CHANNEL FROM MAPPING
3390: VDESCD: PUSHJ P,VDESET
3391:         POPJ P,
3392:         PUSHJ P,VDBIT
3393:         CAIL AC1,40
3394:         MOVEI AC3,17    ;ANY HIGH # CLEARS ANALOG SELECT
3395:         PUSHJ P,VDSTR
3396:         ANDCAM AC3,VDTMP(AC2)
3397:         JRST VDOUT
3398: 
3399: ;SELECT SINGLE CHANNEL INTO MAPPING
3400: VDESCS: PUSHJ P,VDESTV          ;<ESC>S
3401:         PUSHJ P,VDECHK
3402:         PUSHJ P,VDVCHK
3403:         MOVEM AC1,VDTMP(AC2)
3404:         PUSHJ P,VDSTRB
3405:         MOVEM AC3,VDTMP(AC2)
3406:         JRST VDOUT
3407: 
3408: ;SELECT SINGLE CHANNEL TEMPORARILY
3409: VDESCT: PUSHJ P,VDESTV
3410:         PUSHJ P,VDECHK
3411:         TRZN AC1,-40
3412:         JRST VDESC2
3413:         ANDI AC1,7
3414:         SKIPA AC3,VDSYNC(AC1)
3415: VDESC2: PUSHJ P,VDBIT
3416:         SKIPE AC2,LETAB+DPYNUM(TAC)
3417:         MOVEM AC3,VDTMP(AC2)
3418:         JRST VDOUT
3419: 
3420: VDESTV: JUMPGE AC1,CPOPJ        ;<ESC>S OR <ESC>T OR <ESC>A
3421:         CAME AC1,[-ESCNUL]      ;SKIP IF <BRK>
3422:         POPJ P,
3423:         PUSH P,AC1
3424:         PUSH P,TAC
3425:         HRRZI AC1,ASTVC         ;TV AUDIO CHANNEL
3426:         PUSHJ P,ASESC           ;SIMULATE ESC # U WHERE # = ASTVC
3427:         POP P,TAC
3428:         POP P,AC1
3429:         POPJ P,
    TTYSER page# 0060 next  prev
3431: ;MORE ESCAPES   VDESET  VDECHK  VDVCHK
3432: ;SET UP ARGS FOR VD CMDS, SKIP IF LEGAL.
3433: ;NO ARG => MY CHAN. + ARG => DD CHAN #. - ARG => CHAN FOR TTY #.
3434: VDESET: HRRI TAC,-DDL0(LINE)
3435:         MOVE AC2,LINTAB+DDL0(TAC)
3436:         TLNN AC2,DDDLIN
3437:         JRST VDEST4
3438:         JUMPL AC1,VDEST3
3439:         CAIE AC1,ESCNUL
3440:         JRST ESCOCS
3441:         MOVEI AC1,-DDL0(AC2)
3442:         TLO TAC,200000
3443: VDEST2: SKIPN AC2,LETAB+DPYNUM(AC1)
3444:         SKIPA AC1,AVLCHN
3445:         HLRZ AC1,PRGNUM(AC2)
3446:         JRST CPOPJ1
3447: 
3448: VDEST3: MOVN AC1,AC1
3449:         CAIN AC1,ESCNUL
3450:         JRST VDEST1
3451:         PUSHJ P,ESCOCT
3452:         SUBI AC1,DDL0
3453:         CAIGE AC1,DDNUM
3454:         JUMPGE AC1,VDEST2
3455:         POPJ P,
3456: 
3457: VDEST1: MOVEI AC1,45            ;<BRK> WITH NO ARG IS ALWAYS TV CHANNEL
3458:         JRST CPOPJ1             ;RPH OCT-27-72
3459: 
3460: VDEST4: TLNE AC2,DISLIN         ;NOT DD, SEE IF III
3461:         SKIPN LETAB+DPYNUM(TAC)
3462:         POPJ P,                 ;NOT III OR NO DPY HEADER MEANS ILLEGAL
3463:         JUMPL AC1,CPOPJ
3464:         HRROI TAC,(TAC)         ;(THANK YOU MR. FROST - REG) SET SIGN FOR VDSTRI
3465:         CAIN AC1,ESCNUL
3466:         SKIPA AC1,[-4,,]        ;NULL ARG MEANS ALL P OF G'S
3467:         PUSHJ P,ESCOCT
3468:         TRNN AC1,-20
3469:         AOS (P)                 ;SKIP IF LEGAL P OF G #
3470:         POPJ P,
3471: 
3472: ;SET UP ARGS & CHECK PRIVACY. RETURNS UPLEVEL ON LOSSAGE
3473: VDECHK: PUSHJ P,VDESET
3474:         JRST TPOPJ
3475:         TLNE TAC,200000
3476:         POPJ P,
3477:         CAIGE AC1,40
3478:         SKIPL DDTAB(AC1)
3479:         POPJ P,
3480:         MOVEI AC3,(TAC)
3481:         MOVEI J,
3482:         PUSHJ P,VDCCHK
3483:         SUB P,[1,,1]
3484:         POPJ P,
3485: 
3486: ;CHECK IF CHANNEL IS REALLY ANALOG, AND HANDLE SPECIALLY
3487: VDVCHK: TRZN AC1,-40
3488:         JRST CPOPJ1
3489:         ANDI AC1,7
3490:         IOR AC1,VDSYNC(AC1)
3491:         PUSHJ P,VDSTR
3492:         XCT @-1(P)
3493:         SUB P,[1,,1]
3494:         JRST VDOUT
    TTYSER page# 0061 next  prev
3496: ;ASSCN, ASESC, ESCB  AUDIO SWITCH SERVICE
3497: 
3498: ;ASBTAB HAS DURATION OF BEEP IN 1/4 SEC UNITS
3499: ;IF NON-ZERO, INDICATES BEEP IS HAPPENING
3500: 
3501: ;ASTAB BITS
3502: ;RH HAS TIME REMAINING IN TEMP SELECTION IN 1/4 SEC UNITS
3503: ;       ZERO MEANS INFINITE
3504: ;BITS     FUNCTION
3505: ;0     => UUO IS HANGING UNTIL TEMPORARY SELECTION TIMES OUT
3506:         ASHANG←←400000
3507:         ASHGBP←←430100
3508: ;1     => CURRENT SELECTION IS TEMPORARY
3509:         ASTEMP←←200000
3510: ;2     => PAGING NOW
3511:         ASPAGN←←100000
3512: ;3     => BEEP WHEN TEMPORARY SELECTION TIMES OUT
3513:         ASDBEP←←40000
3514: ;4     => PERMANENT CHANNEL NOT PAGE INTERRUPTIBLE
3515:         ASPPUN←←20000
3516:         ASPPUP←←370100
3517: ;5     => PERMANENT CHANNEL NOT BEEP INTERRUPTIBLE
3518:         ASPBUN←←10000
3519:         ASPBUP←←360100
3520: ;6-7   => TEMPORARY CHANNEL BEEPING DISPOSITION
3521:         ASBPDP←←340200
3522: ;8-9   => TEMPORARY CHANNEL PAGING DISPOSTION
3523:         ASPGDP←←320200
3524: ;10-13 => TEMPORARY CHANNEL NUMBER
3525:         ASTMPP←←260400
3526:         ASTMPM←←360
3527: ;14-17 => PERMANENT CHANNEL NUMBER
3528:         ASPRMP←←220400
3529:         ASPRMM←←17      ;MASK
3530: 
3531: ;DISPOSITION CODES
3532:         ;0: INTERRUPTIBLE
3533:         ;1: NON-INTERRUPTIBLE
3534:         ;2: INTERRUPTIBLE, BUT EXTEND DURATION OF TEMP CH
3535:         ;3: POSTPONE BEEP UNTIL TEMP SELECTION TIMES OUT
3536: 
3537: ;NOTE: 3 IS APPLICABLE ONLY TO BEEP DISPOSITION
3538: 
3539: ASPAGC←←0                       ;AUDIO SWITCH PAGING CHANNEL
3540: ASTVC←←1                        ;AUDIO SWITCH TV CHANNEL
3541: ASBEPC←←5                       ;AUDIO SWITCH BEEP CHANNEL
3542: ASBPTM←←3                       ;3/4 SEC FOR BEEP
3543: 
3544: ;AUDIO SWITCH CHANNEL PERMANENT SELECTION
3545: ASESC:  HRREI TAC,-DPYL0(LINE)
3546:         JUMPL TAC,CPOPJ         ;NOT A DPY
3547:         CAIL TAC,DPYNUM+DDNUM
3548:         POPJ P,
3549:         MOVEI DSER,0
3550:         JUMPGE AC1,ASESC1       ;JUMP IF PAGE INTERRUPTIBLE PERM SELECTION ESC U
3551:         MOVN AC1,AC1            ;BRK#U MAKE PAGE UNINT.PERMANENT SELECTION
3552:         MOVEI DSER,ASPPUN       ;PERM PAGE UNINTERRUPTIBLE
3553: ASESC1: CAIN AC1,ESCNUL
3554:         MOVEI AC1,ASPAGC-3*=10+ASPAGC&7        ;FAKE OUT ESCOCT
3555:         PUSHJ P,ESCOCT          ;ASSUME TYPEIN WAS OCTAL
3556: ASSEL:  LDB AC3,[ASHGBP,,ASTAB(TAC)]    ;UUO HANG BIT
3557:         IORI AC1,(DSER)         ;PERM SELECTION AND MAYBE PPUN BIT
3558:         HRLZM AC1,ASTAB(TAC)    ;CLEAR ALL OTHER BITS
3559:         SETZM ASBTAB(TAC)       ;CLEAR BEEP DURATION
3560:         HRLI AC1,(TAC)
3561:         DATAO AS,AC1            ;DO SELECTION NOW
3562:         JUMPN AC3,ASUNHG        ;UNHANG POOR UUO
3563:         POPJ P,
3564: 
3565: 
3566: ASSCN: CONO PK,0               ;MAKE SURE WE DON'T RUN PAGING INT CODE
3567:         MOVSI TAC,-<DPYNUM+DDNUM>
3568:         MOVEI TAC1,-1
3569: ASSCNL: TDNE TAC1,ASBTAB(TAC)   ;CHECK FOR BEEPING GOING ON
3570:         JRST ASSCB
3571:         TDNN TAC1,ASTAB(TAC)    ;SKIP IF NON-INFINITE TEMP SELECTION
3572:         JRST ASSCLN
3573:         MOVE AC1,ASTAB(TAC)
3574:         LDB AC2,[ASPGDP,,AC1]           ;TEMP PAGE DISPOSITION
3575:         TLNN AC1,ASPAGN
3576:         JRST ASSCN1             ;NOT PAGING NOW
3577:         CAIN AC2,2
3578:         JRST ASSCLN             ;PAGING AND EXTEND, SO DON'T COUNT TEMP DURATION
3579: ASSCN1: SOS AC1,ASTAB(TAC)      ;DECREASE ITS COUNT
3580:         TRNN AC1,-1             ;SKIP IF NOT TIME YET
3581:         JRST ASSCTO             ;TIMED OUT, SET BACK TO PERMANENT
3582: ASSCLN: AOBJN TAC,ASSCNL
3583:         CONO PK,PKCHN
3584:         POPJ P,
3585: 
3586: ;IN MIDDLE OF BEEP (CAN'T BE IN A PAGE -- SEE PKINT)
3587: ASSCB:  SOS AC1,ASBTAB(TAC)     ;DECREMENT BEEP DURATION
3588:         MOVE AC2,ASTAB(TAC)
3589:         TLNN AC2,ASTEMP         ;SKIP IF BEEP INTERRUPTED TEMP SEL
3590:         JRST ASSCB1             ;BEEP IS DURING PERM SEL
3591:         LDB AC2,[ASBPDP,,AC2]   ;TEMP BEEP DISPOSITION
3592:         TDNE TAC1,ASTAB(TAC)    ;IF TEMP SEL IS INFINITE OR ...
3593:         CAIN AC2,2
3594:         JRST ASSCB1             ;IF EXTEND, THEN DON'T COUNT TEMP DURATION
3595:         SOS AC2,ASTAB(TAC)
3596:         TRNN AC2,-1             ;IF TEMP RUNS OUT DURING BEEP, ...
3597:         TLZ AC2,ASTEMP          ;MAKE IT LOOK LIKE INTERRUPTED PERM
3598:         MOVEM AC2,ASTAB(TAC)
3599: ASSCB1: TRNE AC1,-1
3600:         JRST ASSCLN             ;BEEP NOT DONE, CONTINUE SCAN
3601: ASRVRT: MOVE AC1,ASTAB(TAC)
3602:         TLZE AC1,ASDBEP
3603:         JRST ASRVR1             ;GO AND BEEP
3604:         TLNE AC1,ASTEMP         ;SKIP IF GOING BACK TO PERM
3605:         JRST ASRVR3             ;GOING BACK TO TEMP
3606:         TLNE AC1,ASHANG         ;SKIP IF UUO NOT HUNG
3607:         PUSHJ P,ASUNHG          ;UNHANG UUO
3608:         LDB AC2,[ASPRMP,,AC1]   ;PERM SEL
3609: ASRVR2: HRLI AC2,(TAC)
3610:         DATAO AS,AC2
3611:         JRST ASSCLN             ;CONTINUE SCAN
3612: 
3613: ASRVR3: LDB AC2,[ASTMPP,,AC1]   ;TEMP SEL
3614:         JRST ASRVR2
3615: 
3616: ASRVR1: MOVEM AC1,ASTAB(TAC)    ;STORE BACK WITH BEEP BIT OFF
3617:         MOVEI AC2,ASBPTM
3618:         MOVEM AC2,ASBTAB(TAC)   ;SET UP BEEP DURATION
3619:         MOVEI AC2,ASBEPC
3620:         JRST ASRVR2             ;SELECT BEEP CHANNEL AND CONTINUE SCAN
3621: 
3622: ASSCTO: TLZ AC1,ASTEMP          ;TEMP SEL TIMED OUT, CLEAR TEMP BIT
3623:         TLNE AC1,ASPAGN
3624:         JRST ASSCT2             ;PAGING NOW
3625:         TLZE AC1,ASDBEP
3626:         JRST ASRVR1             ;DO DELAYED BEEP
3627:         MOVEM AC1,ASTAB(TAC)
3628:         TLNE AC1,ASHANG
3629:         PUSHJ P,ASUNHG          ;UNHANG UUO
3630: ASSCT1: LDB AC2,[ASPRMP,,AC1]
3631:         JRST ASRVR2             ;SELECT PERM AND CONTINUE SCAN
3632: 
3633: ASSCT2: MOVEM AC1,ASTAB(TAC)    ;JUST CLEAR TEMP BIT AND
3634:         JRST ASSCLN             ;CONTINUE SCAN
3635: 
3636: ;UNHANG UUO THAT WAS WAITING FOR TEMP SEL TO FINISH
3637: ASUNHG: PUSH P,DDB
3638:         PUSH P,J
3639:         MOVSI J,ASHANG
3640:         ANDCAM J,ASTAB(TAC)     ;CLEAR UUO HANG BIT
3641:         HRRZ DDB,TTYTAB+DPYL0(TAC)
3642:         JUMPE DDB,ASUNHR        ;NO DDB, DONE
3643:         MOVSI J,TTYATC
3644:         TDNN J,DEVMOD(DDB)
3645:         JRST ASUNHR             ;NOT CONSOLE, DONE
3646:         LDB J,PJOBN             ;JOB NUMBER
3647:         MOVM DDB,JOBQUE(J)
3648:         CAIE DDB,IOWQ
3649:         JRST ASUNHR             ;NOT IN IOWQ NOW
3650:         MOVEI DDB,RUNQ          ;GRONK INTO RUNQ
3651:         MOVNM DDB,JOBQUE(J)
3652:         PUSHJ P,REQUE
3653: ASUNHR: POP P,J
3654:         POP P,DDB
3655:         POPJ P,
3656: 
3657: ESCB:   HRREI AC2,-DPYL0(LINE)
3658:         JUMPL AC2,CPOPJ
3659:         CAIL AC2,DDNUM+DPYNUM
3660:         POPJ P,                 ;NOT A DPY
3661:         MOVSI TAC,ASPBUN
3662:         JUMPL AC1,ESCB1
3663:         ANDCAM TAC,ASTAB(AC2)   ;ESC B MAKES YOU BEEP INTERRUPTIBLE
3664:         POPJ P,
3665: 
3666: ESCB1:  IORM TAC,ASTAB(AC2)     ;BRK B MAKES YOU BEEP UNINTERRUPTIBLE
3667:         POPJ P,
    TTYSER page# 0062 next  prev
3669: ;PKINT  PAGING INTERRUPT SERVICE ROUTINE
3670: 
3671: PKCHN←←5                       ;PI CHANNEL FOR PAGING KLUDGE
3672: PKINTB←←10                     ;INTERRUPT BIT IN CONI
3673: PKPAGE←←20                     ;PAGING BIT IN CONI
3674: PKSET←←10
3675: PKCLR←←20
3676: 
3677: PKINT: JSR PKSAV               ;SAVES ACS AND PUSHJS TO .+1
3678:         CONO PK,PKCLR!PKCHN
3679:         MOVSI TAC,-<DPYNUM+DDNUM>
3680:         CONSO PK,PKPAGE         ;SKIP IF PAGING JUST BEGINNING
3681:         JRST PKINND             ;PAGING FINISHED
3682:         SETOM PAGNOW            ;INDICATE PAGING NOW IN PROGRESS
3683:         MOVEI TAC1,-1
3684: PKINL:  MOVEI DSER,0            ;-1 => BEEPING
3685:         TDNE TAC1,ASBTAB(TAC)
3686:         MOVNI DSER,1            ;BEEPING NOW
3687:         MOVE AC1,ASTAB(TAC)
3688:         TLNN AC1,ASTEMP         ;SKIP IF TEMP SELECTION NOW IN FORCE
3689:         JRST PKINP              ;PERM
3690:         LDB AC2,[ASPGDP,,AC1]
3691:         CAIN AC2,1
3692:         JRST PKINLA             ;NOT PAGE INTERRUPTIBLE
3693: PKINLB: JUMPE DSER,PKINL1       ;NOT BEEPING, JUST DO IT
3694:         HLLZM ASBTAB(TAC)       ;FLUSH BEEP
3695:         TLO AC1,ASDBEP          ;SET DELAYED BEEP BIT
3696: PKINL1: TLO AC1,ASPAGN          ;PAGING NOW
3697:         MOVEM AC1,ASTAB(TAC)
3698:         MOVEI AC2,ASPAGC
3699:         HRLI AC2,(TAC)
3700:         DATAO AS,AC2
3701: PKINLA: AOBJN TAC,PKINL
3702:         POPJ P,
3703: 
3704: ;PERMANENT SELECTION IS NOW IN FORCE
3705: PKINP:  TLNE AC1,ASPPUN         ;SKIP IF PAGE INTERRUPTIBLE
3706:         JRST PKINLA             ;CONTINUE SCAN
3707:         JRST PKINLB
3708: 
3709: ;HERE IF PAGING INTERRUPT BUT PAGING BIT IS OFF
3710: PKINND: SETZM PAGNOW
3711:         MOVE AC1,ASTAB(TAC)
3712:         TLZN AC1,ASPAGN         ;SKIP IF HAS BEEN INTERRUPTED FOR PAGING
3713:         JRST PKINNA             ;DON'T HAVE TO MUNG HIM
3714:         TLZN AC1,ASDBEP         ;SKIP IF HAVE TO DO BEEP NOW
3715:         JRST PKINN1
3716:         MOVEI AC2,ASBPTM
3717:         MOVEM AC2,ASBTAB(TAC)   ;SET UP BEEP DURATION
3718:         MOVEI AC2,ASBEPC        ;SELECT BEEP CHANNEL AND CONTINUE SCAN
3719: PKINN2: MOVEM AC1,ASTAB(TAC)
3720:         HRLI AC2,(TAC)
3721:         DATAO AS,AC2
3722: PKINNA: AOBJN TAC,PKINND
3723:         POPJ P,
3724: 
3725: ;DELAYED BEEP BIT WAS OFF
3726: PKINN1: TLNN AC1,ASTEMP         ;SKIP IF GOING BACK TO TEMP SEL
3727:         JRST PKINNP
3728:         LDB AC2,[ASTMPP,,AC1]   ;TEMP CHANNEL SELECTION
3729:         JRST PKINN2
3730: 
3731: ;GOING BACK TO PERMANENT SELECTION
3732: PKINNP: TLZE AC1,ASHANG         ;SKIP IF UUO NOT HANGING
3733:         PUSHJ P,ASUNHG          ;UNHANG THE UUO
3734:         LDB AC2,[ASPRMP,,AC1]   ;PERMANENT CHANNEL SELECTION
3735:         JRST PKINN2
    TTYSER page# 0063 next  prev
3737: ;ADSMAP, BEEP UUOS
3738: 
3739: ;ADSMAP AC, (EFFECTIVE ONLY FROM A JOB THAT IS ATTACHED TO ITS CONSOLE)
3740: ;AC BITS
3741: ;0      1 => TEMPORARY, 0=> PERMANENT
3742: ;1      1 => SET SELECTION, 0 => READ
3743: ;2      1 => MAKE THE SELECTION IMMEDIATELY (IF TEMP SEL)
3744: ;3      1 => DON'T HANG UNTIL PREVIOUS TEMP SEL IS COMPLETE
3745: ;4      1 => DON'T HANG UNTIL THIS TEMP SEL IS COMPLETE
3746: ;5-6    PAGING DISPOSITION
3747: ;7-8    BEEPING DISPOSITION
3748: ;14-17  NEW SELECTION (AS CHANNEL NUMBER)
3749: ;RH     DURATION FOR TEMP SEL IN 1/4 SEC UNITS
3750: 
3751: ;THE FOLLOWING ADDITIONAL BITS ARE RETURNED ON A READ STATUS:
3752: ;9      1 => THERE IS AN ACTIVE TEMP MAP FOR THIS LINE
3753: ;10     1 => THERE IS A PAGE IN PROGRESS (WHETHER OR NOT ON THIS LINE)
3754: ;11     1 => THERE IS A PAGE IN PROGRESS AND ENABLED ON THIS LINE
3755: ;12     1 => THERE IS A BEEP IN PROGRESS ON THIS LINE
3756: ;13     1 => THERE IS A DELAYED BEEP PENDING FOR THIS LINE
3757: 
3758: ;IF THE AC CONTAINS -1, THE MAP IS RESET TO ITS PERMANENT STATUS
3759: 
3760: ;IF TRYING TO MAKE A TEMP SEL WITHOUT WAITING FOR THE PREVIOUS TEMP
3761: ;SEL TO FINISH, THE UUO WILL BE IGNORED IF THE PREV TEMP SEL HAS NOT
3762: ;COMPLETED AND BIT 2 IS ZERO
3763: 
3764: ;IF PERMANENT THEN ONLY LOW BIT OF DISPOSITION FIELD IS LOOKED AT
3765: 
3766: ;DISPOSITIONS
3767: ;0      INTERRUPTIBLE
3768: ;1      NON-INTERRUPTIBLE
3769: ;2      INTERRUPTIBLE, BUT EXTEND DURATION OF TEMP CH
3770: ;3      POSTPONE BEEP UNTIL TEMP SELECTION TIMES OUT
3771: 
3772: ;NOTE: 3 IS APPLICABLE ONLY TO BEEP DISPOSITION
3773: 
3774: ADSMAP:        HRRE AC1,JBTLIN(J)
3775:         JUMPL AC1,CPOPJ         ;DETACHED
3776:         SUBI AC1,DPYL0
3777:         JUMPL AC1,CPOPJ         ;NOT DD OR DPY
3778:         CAIL AC1,DPYNUM+DDNUM
3779:         POPJ P,                 ;NOT DD OR DPY
3780:         MOVE AC2,TAC
3781:         AOJE AC2,ADSRE2         ;TAC=-1 MEANS RESET TO PERM
3782:         TLNN TAC,200000         ;SKIP IF SETTING SELECTION
3783:         JRST ADSMRD             ;READ SELECTION
3784:         CONO PI,SCNOFF
3785:         TLNN TAC,140000         ;SKIP IF DON'T HAVE TO WAIT FOR PREV TEMP SEL
3786:         PUSHJ P,ADSMWT          ;WAIT FOR PREV (TURNS SCNOFF)
3787:         JUMPL TAC,ADSMT         ;MAKE TEMP SEL
3788: ADSRE1: HLRZ TAC,TAC            ;GET NEW CH # IN LOW 4 BITS
3789:         MOVEI AC2,0
3790:         DPB TAC,[ASPRMP,,AC2]   ;PERM CH #
3791:         MOVSI AC3,ASDBEP
3792:         TDNE AC3,ASTAB(AC1)
3793:         IOR AC2,AC3             ;SET DELAYED BEEP BIT IF ALREADY SET
3794:         LDB AC3,[000400,,TAC]   ;CHANNEL TO SELECT TO
3795:         TRNN TAC,4000           ;SKIP IF PAGE UNINTERRUPTIBLE
3796:         JRST [  PUSHJ P,ADSMP1
3797:                 JRST .+2]
3798:         TLO AC2,ASPPUN          ;SET PERM PAGE UNINTERRUPTIBLE BIT
3799:         TRNN TAC,1000           ;SKIP IF BEEP UNINTERRUPTIBLE
3800:         JRST [  PUSHJ P,ADSMP2
3801:                 JRST ADSMP4]
3802:         TLO AC2,ASPBUN          ;SET PERM BEEP UNINTERRUPTIBLE BIT
3803:         TLZ AC2,ASDBEP          ;CLEAR DELAYED BEEP BIT IF NOT INTERRUPTIBLE
3804:         SETZM ASBTAB(AC1)       ;FLUSH BEEPS
3805: ADSMP4: MOVEM AC2,ASTAB(AC1)
3806:         HRLI AC3,(AC1)
3807:         DATAO AS,AC3            ;MAKE SELECTION NOW
3808:         TRNN TAC,400000
3809:         JRST ADSSCZ             ;MAKING PERM SEL, SO DON'T WAIT
3810:         TRNN TAC,20000
3811:         PUSHJ P,ADSMWT          ;WAIT FOR TEMP SEL TO FINISH
3812: ADSSCZ: CONO PI,SCNON
3813:         POPJ P,
3814: 
3815: ;PAGE INTERRUPTIBLE, SO CHECK FOR PAGING GOING ON
3816: ADSMP1: SKIPN PAGNOW
3817:         POPJ P,
3818:         TLO AC2,ASPAGN          ;SET PAGING NOW BIT
3819:         MOVEI AC3,ASPAGC        ;SELECT PAGING CHANNEL
3820:         HRRZ DSER,ASBTAB(AC1)
3821:         JUMPE DSER,CPOPJ        ;NOT BEEP IN PROGRESS
3822:         TLO AC2,ASDBEP          ;SET DELAYED BEEP BIT
3823:         SETZM ASBTAB(AC1)       ;FLUSH BEEP
3824:         POPJ P,
3825: 
3826: ;BEEP INTERRUPTIBLE, SO CHECK FOR DELAYED BEEP OR BEEP IN PROGRESS
3827: ADSMP2: TLNE AC2,ASDBEP         ;SKIP IF NO DELAYED BEEP
3828:         JRST ADSMP5
3829:         HRRZ DSER,ASBTAB(AC1)
3830:         JUMPE DSER,CPOPJ        ;NO BEEP IN PROGRESS EITHER
3831:         MOVEI AC3,ASBEPC        ;CONTINUE WITH BEEP
3832:         POPJ P,
3833: ADSMP5: TLNE AC2,ASPAGN
3834:         POPJ P,                 ;PAGING TAKES PRECEDENCE
3835:         TLZ AC2,ASDBEP          ;CLEAR DELAYED BEEP BIT
3836:         MOVEI AC3,ASBPTM
3837:         MOVEM AC3,ASBTAB(AC1)   ;START UP BEEP
3838:         MOVEI AC3,ASBEPC
3839:         POPJ P,
3840: 
3841: ;MAKE TEMP SEL (SCNOFF)
3842: ADSMT:  MOVE AC2,ASTAB(AC1)
3843:         TRNE AC2,-1             ;SKIP IF NO TEMP SEL IN PROG OR INF TEMP SEL IS
3844:         TLNE TAC,100000         ;SKIP IF GRONK IS OFF
3845:         JRST ADSMT1             ;OK TO MAKE NEW TEMP SEL NOW
3846:         JRST ADSSCZ             ;TEMP SEL IN PROG, DON'T GRONK, DON'T WAIT (NOOP)
3847: ADSMT1: MOVS TAC,TAC            ;NEW CH # IN LOW 4 BITS, DURATION IN LH
3848:         LDB AC3,[000400,,TAC]   ;NEW CHAN SELECTION
3849:         DPB AC3,[ASTMPP,,AC2]
3850:         LDB TAC1,[130200,,TAC]  ;NEW PAGING DISPOSITION
3851:         CAIN TAC1,3
3852:         MOVEI TAC1,1            ;CHANGE 3 INTO 1
3853:         DPB TAC1,[ASPGDP,,AC2]  ;SET PAGE DISP
3854:         LDB TAC1,[110200,,TAC]  ;NEW BEEP DISPOSITION
3855:         DPB TAC1,[ASBPDP,,AC2]  ;SET BEEP DISP
3856:         TRNN TAC,400            ;SKIP IF NOT PAGE INTERRUPTIBLE
3857:         PUSHJ P,ADSMP1
3858: ADSMT3: CAIN TAC1,3
3859:         JRST ADSMT4             ;DELAY BEEP
3860:         CAIE TAC1,1             ;SKIP IF BEEP UNINTERRUPTIBLE
3861:         JRST [  PUSHJ P,ADSMP2
3862:                 JRST ADSMT6]
3863:         TLZ AC2,ASDBEP
3864:         SETZM ASBTAB(AC1)
3865: ADSMT6: HLR AC2,TAC             ;DURATION
3866:         TLO AC2,ASTEMP          ;SET TEMP SEL BIT
3867:         JRST ADSMP4
3868: 
3869: ;DELAY BEEP MODE
3870: ADSMT4: HRRZ DSER,ASBTAB(AC1)
3871:         JUMPE DSER,ADSMT6
3872:         TLO AC2,ASDBEP          ;SET DELAYED BEEP BIT
3873:         SETZM ASBTAB(AC1)       ;FLUSH BEEP NOW
3874:         JRST ADSMT6
3875: 
3876: ;WAIT UNTIL TEMP SELECTION IS DONE (RETURNS WITH SCNOFF)
3877: ADSMWT: CONO PI,SCNOFF
3878:         MOVE AC2,ASTAB(AC1)
3879:         TLNE AC2,ASHANG
3880:         JRST ADSMW1
3881:         MOVEI AC3,-1
3882:         TDNN AC3,ASBTAB(AC1)    ;SKIP IF BEEPING NOW
3883:         TLNE AC2,ASPAGN         ;SKIP IF NOT PAGING NOW
3884:         JRST ADSMW1             ;BEEP OR TEMP SEL - WAIT
3885:         TRNN AC2,-1             ;NOT BEEPING OR PAGING,TEST FOR TEMP SEL TO WAIT FOR
3886:         POPJ P,                 ;NOTHING TO WAIT FOR
3887: ADSMW1: TLO AC2,ASHANG
3888:         MOVEM AC2,ASTAB(AC1)
3889:         MOVEI AC2,IOWQ
3890:         MOVNM AC2,JOBQUE(J)
3891:         CONO PI,SCNON
3892:         PUSHJ P,WSCHED          ;GO INTO IOWQ
3893:         JRST ADSMWT
3894: 
3895: ;READ AS STATUS INTO AC
3896: ADSMRD: CONO PI,SCNOFF          ;PREVENT CHANGING OUT FROM UNDER US
3897:         MOVE AC2,PAGNOW
3898:         HRRZ AC3,ASBTAB(AC1)
3899:         MOVE TAC1,ASTAB(AC1)
3900:         CONO PI,SCNON
3901:         HRR TAC,TAC1            ;READ BACK DURATION
3902:         TLZ TAC,177777
3903:         TLNE TAC1,ASTEMP
3904:         TLO TAC,400             ;TEMP MAP IN EFFECT NOW
3905:         JUMPE AC2,.+2
3906:         TLO TAC,200             ;THERE'S A PAGE GOING ON
3907:         TLNE TAC1,ASPAGN
3908:         TLO TAC,100             ;WE'RE PAGING ON THIS LINE
3909:         JUMPE AC3,.+2
3910:         TLO TAC,40              ;WE'RE BEEPING THIS LINE NOW
3911:         TLNE TAC1,ASDBEP
3912:         TLO TAC,20              ;WE'RE GOING TO BEEP IT LATER
3913:         JUMPGE TAC,ADSMR1       ;JUMP IF READING PERM
3914:         LDB AC2,[ASTMPP,,TAC1]  ;TEMP CHAN SEL
3915:         LDB AC3,[ASBPDP,,TAC1]  ;TEMP BEEP DISP
3916:         LDB TAC1,[ASPGDP,,TAC1] ;TEMP PAGE DISP
3917: ADSMR2: LSH TAC1,2
3918:         IOR TAC1,AC3
3919:         LSH TAC1,9
3920:         IORI TAC1,200000(AC2)
3921:         TSO TAC,TAC1
3922:         JRST STOTAC
3923: 
3924: ADSMR1: LDB AC2,[ASPRMP,,TAC1]  ;PERM CHAN SEL
3925:         LDB AC3,[ASPBUP,,TAC1]  ;PERM BEEP UNINTERRUPTIBLE BIT
3926:         LDB TAC1,[ASPPUP,,TAC1] ;PERM PAGE UNINTERRUPTIBLE BIT
3927:         JRST ADSMR2
3928: 
3929: ;BEEP AC,
3930: ;AC HAS TTY NUMBER TO BEEP OR -1 FOR YOURSELF
3931: BEEP:  JUMPGE TAC,BEEP1
3932:         HRRE TAC,JBTLIN(J)
3933:         JUMPL TAC,CPOPJ         ;DETACHED
3934: BEEP1:  ANDI TAC,177
3935:         SUBI TAC,DPYL0
3936:         JUMPL TAC,BEEPND        ;NOT A DPY, TRY ↑G
3937:         CAIL TAC,DPYNUM+DDNUM
3938:         JRST BEEPND
3939:         CONO PI,SCNOFF
3940:         MOVE AC1,ASTAB(TAC)
3941:         LDB AC2,[ASBPDP,,AC1]   ;GET TEMP BEEP DISP
3942:         TLNN AC1,ASTEMP         ;SKIP IF TEMP
3943:         LDB AC2,[ASPBUP,,AC1]   ;PERM BEEP DISP
3944:         TRNE AC2,1              ;SKIP IF INTERRUPTIBLE
3945:         JRST BEEPU
3946:         TLNN AC1,ASPAGN         ;SKIP IF PAGING NOW
3947:         JRST BEEPNP
3948: BEEPDX: TLO AC1,ASDBEP          ;SET DELAYED BEEP
3949:         MOVEM AC1,ASTAB(TAC)
3950: BEEPX:  CONO PI,SCNON
3951:         POPJ P,
3952: 
3953: BEEPNP: MOVEI AC2,ASBPTM
3954:         MOVEM AC2,ASBTAB(TAC)
3955:         MOVEI AC3,ASBEPC
3956:         HRLI AC3,(TAC)
3957:         DATAO AS,AC3
3958:         JRST BEEPX
3959: 
3960: BEEPU:  TLNE AC1,ASTEMP         ;SKIP IF PERM
3961:         CAIN AC2,1
3962:         JRST BEEPX              ;NOT INTERRUPTIBLE, SORRY
3963:         JRST BEEPDX             ;TEMP SEL (INF OR OTHERWISE), SET DELAYED BEEP
3964: 
3965: BEEPND: MOVEI LINE,DPYL0(TAC)   ;BEEP ADDRESSED TO NON-DPY:
3966:         PUSHJ P,GETDBA          ;FIND OR CREATE DDB
3967:         POPJ P,                 ;NO SUCH TTY OR NO DDBS AVAILABLE
3968:         MOVEI CHR,7             ;GOBBLE A BELL
3969:         PUSHJ P,OUTCHR          ;SOCK IT TO HIM!
3970:         JRST TYPTST
3971: 
3972: ;RESET AUDIO SWITCH MAP TO PERMANENT SETTING
3973: ;CALLED BY ADSMAP WITH AC=-1 AND BY RESET
3974: ADSRES:        HRRE AC1,JBTLIN(J)      ;RESET JOB TO PERMANENT ADS MAP
3975:         JUMPL AC1,CPOPJ         ;DETACHED
3976:         SUBI AC1,DPYL0
3977:         JUMPL AC1,CPOPJ         ;NOT DD OR DPY
3978:         CAIL AC1,DPYNUM+DDNUM
3979:         POPJ P,                 ;NOT DD OR DPY
3980: ADSRE2: MOVEI TAC,0
3981:         CONO PI,SCNOFF
3982:         LDB AC2,[ASPPUP,,ASTAB(AC1)]
3983:         DPB AC2,[POINT 1,TAC,6]
3984:         LDB AC2,[ASPBUP,,ASTAB(AC1)]
3985:         DPB AC2,[POINT 1,TAC,8]
3986:         LDB AC2,[ASPRMP,,ASTAB(AC1)]
3987:         DPB AC2,[POINT 4,TAC,17]
3988:         TLO TAC,360000
3989:         JRST ADSRE1
    TTYSER page# 0064 next  prev
3991: ;RECIML
3992: ;SPECIAL CODE FOR IMLACS (JHS CODE REPLACED BY BO)
3993: 
3994: RECIML: TLZE IOS,IMLTTY         ;Flag left from preceding char?
3995:         JRST RECIM1             ;Yes.  Add the bucky bits.
3996: 
3997:         TRNN CHR,200            ;No.  Test the 8th bit.
3998:         JRST RECIM2             ;Off.  Just plain data.
3999: 
4000:         TLO IOS,IMLTTY          ;On.  Flag it as extra special.
4001:         CAIL CHR,241            ;Is it a prefix meaning bucky bits?
4002:         CAILE CHR,243
4003:         JRST RECIM2             ;No.
4004: 
4005:         DPB CHR,[POINT 2,IMLHAC(DDB),34];Save the bucky bits and
4006:         MOVEM IOS,DEVIOS(DDB)   ;set the IMLTTY flag for the next char
4007:         POPJ P,                 ;and get out fast.
4008: 
4009: RECIM1: LDB UCHN,[POINT 2,IMLHAC(DDB),34]
4010:         JRST RECIM2
    TTYSER page# 0065 next  prev
4012: ;TYPX, COMSET
4013: ;ROUTINE TO TYPE X IF LINE CANNOT GET INTO SYSTEM
4014: 
4015: TYPX:   SUB     P,[1,,1]
4016:         ANDI    CHR,177
4017:         CAIN    CHR,"X"         ;CHAR. RECEIVED AN "X"
4018:         POPJ    P,                      ;YES, MAY BE ECHO, DISMISS INT.
4019:         MOVEI   CHR,"X"
4020:         JRST    TYPL                    ;TYPE OUT "X"
4021: 
4022: ;ROUTINE TO WAKE UP COMMAND DECODER IF TPMON IS SET
4023: 
4024: COMSET:TLNN    IOS,TTYDTC              ;DTACHED GUYS CAN'T SAY ANYTHING!
4025:         TLNN    IOS,TPMON               ;MONITOR MODE?
4026:         POPJ    P,                      ;NO, NOT MONITOR COMMAND
4027:         MOVE    TAC,DEVMOD(DDB)         ;GET SOME GOOD BITS
4028:         TLNN    TAC,TTYATC              ;IF NOT A CONSOLE
4029:         TRNN    TAC,ASSCON!ASSPRG       ;AND ASSIGNED BY PROGRAM OR CONSOLE
4030:         JRST    .+2
4031:         POPJ    P,                      ;THEN HE CAN'T TYPE COMMANDS
4032:         MOVSI   IOS,IOFST
4033:         IORB    IOS,DEVIOS(DDB)
4034:         MOVSI   TAC,COMBIT              ;SET SIGN BIT
4035:         TDNN    TAC,TTYTAB(LINE)        ;SKIP IF COMMAND BIT IS ON
4036:         AOS     COMCNT                  ;COUNT ANOTHER COMMAND WE HAVE
4037:         IORM    TAC,TTYTAB(LINE)        ;IN TTY TRANSLATOR TABLE
4038: IFN FTTTYBUG,<
4039:         PUSHJ   P,COMBCK
4040:         PUSHJ   P,CNTCOM                ;CALL THE DRD
4041: >
4042:         POPJ    P,
    TTYSER page# 0066 next  prev
4044: ;TTEDIT
4045: ;TTY KEYBOARD EDITOR ROUTINE
4046: ;UPON RECEIPT OF A CHARACTER, THIS ROUTINE DETERMINES WHAT TO DO
4047: ;WITH IT: WHETHER IT'S A SPECIAL CHARACTER NEEDING SPECIAL ECHOING,
4048: ;WHETHER SOME OTHER CHARACTER IS TO BE STORED IN ITS PLACE, WHETHER
4049: ;IT IS A BREAK CHARACTER (LINE TERMINATOR), OR WHETHER THE CHARACTER
4050: ;TYPED IS A SIGNAL TO UNDERTAKE SOME SPECIAL ACTION.
4051: ;IN ANY CASE, ALL SPECIAL ACTION, INCLUDING DUPLEXING TAKES PLACE ON
4052: ;THE LEVEL OF THIS ROUTINE.
4053: ;       THIS ROUTINE CALLS SPCHEK, WHICH MAKES USE OF THE  SPECIAL
4054: ;CHARACTER TABLE, SPCTAB. TO MAKE ANY CHANGES IN THE ACTION GENERATED
4055: ;BY SPECIFIC CHARACTERS MAKE THE ALTERATIONS REQUIRED BY THE
4056: ;COMMENTS DESCRIBING SPCTAB.  NOTE THAT IF A CHARACTER IS TO DISPATCH
4057: ;TO A "SPECIAL ACTION ROUTINE" OR A SPECIAL ECHO ROUTINE, THE LEFT
4058: ;HALF OF THE CORRESPONDING CHARACTER-WORD MUST HAVE SPACTN
4059: ;SET  AND THE ADDRESS OF THE SPECIAL ROUTINE MUST BE
4060: ;ASSEMBLED INTO THE RIGHT HALF OF THE WORD.
4061: ;CALL   HAVE 7-BIT ASCII CHARACTER IN CHR
4062: ;       LDB     HPOS,PHPOS
4063: ;       MOVEI   DAT,TTIBUF(DDB)
4064: ;       PUSHJ   P,TTEDIT
4065: ;       RETURN WITH ACTION DONE, SYNC (LH IOS) SET IF BREAK CHAR. STORED
4066: 
4067: TTEDIT: PUSHJ   P,ADJHP         ;ADJUST HP AND CHECK SPECIAL
4068:         JFCL
4069:         TLNE LINE,IMLIN                 ;IF AN IMLAC,
4070:         JRST [  TLZE IOS,IMLTTY         ;TEST CONTROL FLAG.
4071:                 JRST TTEDT0             ;NO SPECIAL ACTIVATION IF ON.
4072:                 CAIN CHR,177            ;LEAVE SPACTN FOR RUBOUT.
4073:                 JUMPE UCHN,TTEDT2       ;EXCEPT WITH BUCKY BITS
4074:                 TLNN TAC,IMLCHR         ;PREVENT SPACTN ON ~ AND α
4075:                 TLNN TAC,ALLSPA         ;AND ANYTHING ELSE THAT'S NOT
4076:                 TLZ TAC,ALLSPA!SPACTN!ECHSUP!SPHPOS     ;ALWAYS SPECIAL.
4077:                 JRST TTEDT2]
4078: TTEDT2: TLNE    LINE,SPCBRK             ;SPECIAL ACTIVATION MODE?
4079:         TLNE IOS,TPMON
4080:         JRST TTEDT0
4081:         PUSH    P,TAC
4082:         PUSHJ   P,SPCACT
4083:         TLO     IOS,SYNC
4084:         POP     P,TAC
4085:         TLNN    TAC,ALLSPA
4086:         TLNN    IOS,SYNC
4087:         CAIA
4088:         TLZ     TAC,SPACTN              ;INHIBIT ANY SPECIAL ACTION IF A BREAK
4089:         JRST    TTEDT1
4090: TTEDT0: TLNE    TAC,BREAKB!FCSBRK
4091:         TLO     IOS,SYNC        ;IT'S A BREAK CHAR.
4092: TTEDT1: MOVEM   IOS,DEVIOS(DDB)         ;SET SYNC
4093:         JUMPL   TAC,(TAC)               ;JUMP IF CHARACTER HAS SPECIAL DISPATCH
4094: TIPACK: CAIG    CHR,"z"
4095:         CAIGE   CHR,"a"         ;LOWER CASE LETTER?
4096:         JRST    TTIPUT                  ;NO
    TTYSER page# 0067 next  prev
4098: ;TTIPUT, DUPLEX, DUPLX1, INBFUL
4099: ;       TLNN IOS,TPMON                  ;ALWAYS GIVE MONITOR UPPER CASE.
4100:         TLNN    LINE,FCS                ;YES. IS THIS TTY IN 37 MODE?
4101:         TRZ     CHR,40                  ;NO. MAKE CHAR UPPER CASE
4102: TTIPUT: TLZE    LINE,ROBTPD             ;HAVE WE BEEN DELETING?
4103:         PUSHJ   P,BSECHO                ;YES. OUTPUT A BACKSLASH
4104: TTIPT1: DPB UCHN,[POINT 2,CHR,28]       ;PUT IN CTRL. BITS.
4105: TTPT2:  PUSHJ   P,PUTCHI                ;PUT CHAR IN INPUT BUFFER
4106:         JRST    INBFUL                  ;IT DIDNT FIT
4107:         TLNN    TAC,ECHSUP              ;SHOULD THIS CHAR BE ECHOED?
4108: DUPLEX: TLNE    LINE,FULTWX             ;IS THIS LINE ECHOING ITSELF?
4109:         JUMPE   UCHN,CPOPJ              ;DON'T ECHO UNLESS CTRL BITS ON.
4110: DUPLX1: TLNN    IOS,TPMON               ;SHOULD ECHO IF IN MONITOR MODE
4111:         TRNN    IOS,NOECHO              ;AND UNLESS USER SAYS NO, IN USER MODE
4112:         JRST    DUPIML                  ;SO ECHO IT.
4113:         POPJ    P,0                     ;DONT ECHO IF REQUESTED NOT TO BY USER
4114: 
4115: INBFUL: CAIN    CHR,600                 ;CHAR WONT FIT. WAS IT ↑C?
4116:         JRST    CNCTS1                  ;YES. PANIC OUT OF THIS BIND
4117:         MOVEI   CHR,7                   ;NO. JUST ECHO BELL TO SHOW LOSS
4118:         JRST PUTCHO                     ;OUTPUT BELL, IF NOT  DPY.
4119: 
4120: DUPIML: JUMPE UCHN,PUTCHO               ;IF BUCKY BITS OFF
4121:         TRNN IOS,NOECHB                 ;OR NOT TO BE ECHOED
4122:         TLNN LINE,IMLIN                 ;OR NOT AN IMLAC,
4123:         JRST PUTCHO                     ;JUST ECHO THE CHAR.
4124:         PUSH P,CHR
4125:         TRNN UCHN,1                     ;<CTL> BIT...
4126:         JRST DUPIM2
4127:         MOVEI CHR,177                   ;ECHO [BS] [VT].
4128:         PUSHJ P,PUTCHO
4129:         MOVEI CHR,13
4130:         PUSHJ P,PUTCHO
4131:         TRNN UCHN,2                     ;<META>...
4132:         JRST DUPIM3
4133: DUPIM2: MOVEI CHR,177                   ;ECHO [BS] [FF].
4134:         PUSHJ P,PUTCHO
4135:         MOVEI CHR,14
4136:         PUSHJ P,PUTCHO
4137: DUPIM3: POP P,CHR                       ;NOW ECHO THE CHAR.
4138:         JRST PUTCHO
    TTYSER page# 0068 next  prev
4140: ;CONTC, CONTOB, CONTO, CONTB, ALTMOD, TTYUNH
4141: ;CALLED WITH A JUMPL TAC,(TAC), WHERE TAC IS LOADED FROM SPCTAB
4142: ;SPECIAL CHARACTER HANDLING ROUTINES
4143: 
4144: 
4145: CONTC:  PUSHJ   P,DELETL                ;SINCE PEOPLE WANT FREE ↑U
4146:         TLNN    LINE,DDDLIN!DISLIN      ; IF THIS IS A DPY
4147:         JRST    .+3
4148:         JUMPG   UCHN,.+2                ;AND IF NO CTRL BITS ARE ON,
4149:         PUSHJ   P,CNCTS1                ;PROCESS CONTROL C IMMEDIATELY.
4150:         MOVE    TAC,SPCTAB              ;SINCE DELETL CLOBBERS TAC
4151:         PUSHJ   P,TTPT2                 ;PLACE IN BUFFER.
4152:         MOVEI   CHR,3
4153:         PUSHJ   P,CNTLEC
4154:         JRST    CRLFEC
4155: 
4156: CONTZ:  PUSHJ   P,CNTLEC                ;OUTPUT ↑C OR ↑Z
4157:         PUSHJ   P,CRLFEC                ;OUTPUT A CRLF
4158:         MOVEI   CHR,3B28!12             ;CHANGE TO INTERNAL CODE.
4159:         TLO     IOS,SYNC
4160:         JRST    TTPT2                   ;ACTIVATE BUT DON'T STORE
4161: 
4162: CONTOB: MOVEI CHR,"O"-100               ;INVENT A ↑O.
4163: CONTO:  PUSHJ   P,SETBF2                ;CLEAR THE OUTPUT BUFFER
4164:         MOVEI   IOS,IOSUPR              ;SET TO JUNK FURTHER OUTPUT
4165:         XORB    IOS,DEVIOS(DDB)
4166:         JRST    CONTU1                  ;ECHO, ETC.
4167: 
4168: CONTU:  TLNE    IOS,DDTM                ;IN DDTMODE,
4169:         JRST    TTIPUT                  ; PASS THIS CHARACTER
4170:         TLZ     LINE,ROBTPD             ;NO MORE BACKSLASH
4171:         PUSHJ   P,DELETL                ;↑U DELETES INPUT LINE
4172: CONTU1: PUSHJ   P,CNTLEC                ;ECHO ↑O OR ↑U
4173:         JRST    CRLFEC                  ;OUTPUT A CRLF AND RETURN WITHOUT
4174:                                         ; STORING THE ↑O OR ↑U
4175: 
4176: ALTMOD: 
4177:         HRRI    TAC,(CHR)               ;SAVE WHICH KIND OF ALTMOD
4178:         TLNN    LINE,IMLIN
4179:         MOVEI   CHR,44                  ;ECHO A $ EXCEPT ON IMLACS.
4180:         PUSHJ   P,AOJDPX
4181:         MOVEI   CHR,(TAC)               ;RESTORE THE CHARACTER
4182:         JRST    TTIPUT                  ;STORE THE CHARACTER
4183: 
4184: ;FOLLOWING CHANGE BY BO ON RPH'S ADVICE
4185: ;CONTF: TLCA    LINE,FCS                ;COMPLEMENT FCS ON ↑F
4186: ;CONTB: TLC     LINE,FULTWX             ;COMPLEMENT FULTWX ON ↑B
4187: ;       POPJ    P,0                     ;AND RETURN WITHOUT STORING THESE
4188: 
4189: CONTB1: TLCA    LINE,FULTWX
4190: CONTF:  TLC     LINE,FCS
4191:         POPJ    P,
4192: 
4193: CONTB:  TLNE    LINE,DISLIN!DDDLIN!PTYLIN
4194:         JRST    CONTB1
4195:         TLNE    LINE,TLKRNG             ;DON'T ALLOW HOLDING IF TALKING.
4196:         POPJ    P,                      ;TALKING
4197: TTYUNH: TLCE    IOS,TTYHLD              ;Toggle the hold flag.
4198:         TLZ     IOS,TOIP                ;If it was on, turn off TOIP.  The
4199:         MOVEM   IOS,DEVIOS(DDB)         ;STO IOS BACK
4200:         POPJ    P,                      ;next call to TYPTST will restart
4201:                                         ;the output.
4202: ;END BO
    TTYSER page# 0069 next  prev
4204: ;RUBOUT, AOJDPX, CONTK, CONTL
4205: RUBOU4: MOVSI   IOS,SYNC                ;IF PAPER TAPE, NO BREAK
4206:         JRST    T0POPJ                  ;OR STORE. RETURN.
4207: RUBOUT:
4208: 
4209: RUBOU3: TLNE    IOS,TPMON               ;IN MONITOR MODE, NOT A BREAK CHAR
4210:         JRST    RUBOU2
4211:         TDNE    IOS,[XWD DDTM,BKSP]
4212:         JRST    TTIPT1                  ;STORE RUBOUT IF DDT OR FCS
4213: RUBOU2: PUSHJ   P,RUBOU4                ;NOT A BREAK AFTER ALL
4214:         LDB     CHR,PUTR(DAT)           ;GET LAST CHAR IN
4215:         PUSHJ   P,DCPUTR                ;BACK UP TIPUTR
4216:         JRST    RUBOU1                  ;IT'S EMPTY ALREADY
4217:         TLON    LINE,ROBTPD             ;MARK IN RUBOUT SEQUENCE
4218:         PUSHJ   P,BSECHO                ;AND OUTPUT BACKSLASH IF FIRST
4219: AOJDPX: AOJA    HPOS,DUPLX1             ;OUTPUT AND COUNT HPOS
4220: 
4221: RUBOU1: TLZE    LINE,ROBTPD             ;END OF INPUT STREAM REACHED
4222:         PUSHJ   P,BSECHO                ;OUTPUT A BACKSLASH
4223:         JRST    CRLFEC                  ;AND A CR LF
4224: 
4225: CONTK:  HRRI    TAC,4                   ;HERE ON V TAB
4226:         SKIPA
4227: CONTL:  HRRI    TAC,10                  ;HERE ON FORMFEED
4228:         TLNN    LINE,PTYLIN             ;THIS TTY HAVE VERT MECHANICS?
4229:         JRST    SIMFF                   ;NO. SIMULATE IT
4230: ; FOR SOME REASON THE FOLLOWING INSTRUCTION WAS A PUSHJ P,TTIPUT, WHICH
4231: ; CAUSED PTYS TO GET  10 26'S (⊗) UPON TYPING ↑L. - JAM (5-21-72)
4232:         JRST    TTIPUT                  ;PUT CHAR IN BUFFER AND ECHO IT
4233: CONTI1: MOVEI   CHR,1                   ;SYNCHRONOUS IDLE CHARACTERS
4234: SIMFF1: PUSHJ   P,DUPLX1                ;OUTPUT ECHO OF LF OR IDL
4235:         TRNE    TAC,17                  ;DONE YET?
4236:         SOJA    TAC,.-2                 ;NO. OUTPUT MORE
4237:         POPJ    P,0                     ;DONE
4238: 
    TTYSER page# 0070 next  prev
4240: ;CONTI, CONTP
4241: SIMFF:  TLO     TAC,ECHSUP              ;DON'T OUTPUT FF OR VT TO A 33
4242:         PUSHJ   P,TTIPUT                ;PUT IT IN BUFFER
4243:         MOVEI   CHR,12          ;SIMULATE WITH LF'S
4244:         JRST    SIMFF1
4245: 
4246: CONTI:  TLNE    LINE,DISLIN!PTYLIN!DDDLIN!IMLIN
4247:         JRST    TTIPUT                  ;ECHO AND RETURN FOR DISPLAYS
4248:         LDB     HPOS,PHPOS
4249:         ANDI    HPOS,7
4250:         CAIE    HPOS,7                  ;IF ONLY 1, WE WILL CONVERT TO SPACE
4251:         TLNE    LINE,TBXPND             ;FORCING TAB EXPANSION?
4252:         TLO     TAC,ECHSUP              ;YES. DON'T OUTPUT TAB TO 33
4253:         PUSHJ   P,TTIPUT                ;PUT IN BUFFER AND MAYBE ECHO
4254:         TLNE    LINE,TBXPND             ;EXPANDING TABS?
4255:         JRST    CONTI2                  ;YES
4256:         LDB     CHR,PHPOS               ;WHERE WAS TTY BEFORE TAB
4257:         ANDI    CHR,7           ;JUST LOW PART FOR INDEX
4258:         MOVEI   TAC,1           ;ASSUME 1
4259:         XCT     (CHR)[  AOJA TAC,CONTI1 ;8 SPACES-2 IDLES
4260:                         JRST CONTI1     ;7 SPACES-1 IDLE
4261:                         JRST CONTI1     ;6 SPACES-1 IDLE
4262:                         JRST CONTI1     ;5 SPACES-1 IDLE
4263:                         JRST CONTI1     ;4 SPACES-1 IDLE
4264:                         POPJ P,         ;3 SPACES-0 IDLES
4265:                         POPJ P,         ;2 SPACES-0 IDLES
4266:                         JFCL    ]       ;1 SPACE -CONVERT TO SPACE (OR CTY WILL MISS TAB STOP)
4267: CONTI2: MOVEI   CHR,40          ;SPACES FOR THE 33'S
4268:         LDB     HPOS,PHPOS              ;WHERE WAS I BEFORE TAB?
4269:         PUSHJ   P,AOJDPX                ;OUTPUT A SPACE
4270:         TRNE    HPOS,7                  ;AT A TAB STOP?
4271:         JRST    .-2                     ;NO. MORE SPACES.
4272:         POPJ    P,0                     ;RETURN FROM TTEDIT
4273: 
4274: CONTP:  MOVE    TAC,LINBIT(LINE)        ;GET HIS INITIAL LINE BITS
4275:         TLNE    TAC,TBXPND              ;CAN ONLY TOGGLE IF HE HAS HARDWARE TABS!!!
4276:         JRST    NCONTP                  ;NO CAN DO
4277:         TLC     LINE,TBXPND             ;INVERT STATE OF TABS!
4278:         POPJ    P,
4279: 
4280: NCONTP: SETZ TAC,                       ;MAKE SURE IT ECHOS!
4281:         JRST    TTIPUT                  ;AND BACK TO THE MAIN STREAM
    TTYSER page# 0071 next  prev
4283: ;CRLFEC, CRLF
4284: CRLFEC: MOVEI   HPOS,0                  ;ECHO A CR LF, SAVING CHR
4285:         PUSH    P,CHR
4286:         MOVEI   CHR,15                  ;CARRIAGE RETURN
4287:         PUSHJ   P,DUPLX1                ;OUTPUT IT
4288:         MOVEI   CHR,12                  ;LINE FEED
4289:         PUSHJ   P,DUPLX1                ;OUTPUT THAT TOO
4290: CHPOPJ: POP     P,CHR                   ;RESTORE CHR
4291:         POPJ    P,0
4292: 
4293: CNTLEC: 
4294:         HRRI    TAC,100(CHR)            ;SAVE UN-CNTL CHARACTER
4295:         MOVEI   CHR,"↑"
4296:         PUSHJ   P,AOJDPX
4297:         MOVEI   CHR,(TAC)               ;TYPE ↑ CHAR
4298:         PUSHJ   P,AOJDPX
4299:         TRZ     CHR,100                 ;RESTORE IT TO A CNTL CHAR
4300:         POPJ    P,0
4301: 
4302: CRLF:   MOVEI   HPOS,0                  ;HERE ON INPUT OF A CARRIAGE RETURN
4303:         TLNE    LINE,PTYLIN             ; IS THIS A PTY
4304:         JRST    CRLFIP                  ; YES, TEST XON ALWAYS
4305:         TLNE    IOS,TPMON               ; ALWAYS GIVE LF AFTER CR IN MON. MODE
4306:         JRST    CRLFMM
4307: CRLFIP: TLNE    LINE,XON                ;IF PAPER TAPE, NO FREE LF
4308:         JRST    TTIPUT                  ;JUST STORE THE CR
4309: CRLFMM: PUSHJ   P,TTIPUT                ;ORDINARILY, STORE AND GO ON HERE
4310:         MOVEI   CHR,12                  ;BY ADDING A LF
4311:         MOVSI   IOS,SYNC                ;WHICH IS AN ACTIVATOR
4312:         IORB    IOS,DEVIOS(DDB)
4313:         TLNN    LINE,FULTWX             ;IF NOT SELF ECHOING,
4314:         JRST    TTIPUT                  ;THIS WILL GIVE LF ECHO
4315:         PUSHJ   P,TTIPUT                ;OTHERWISE, THIS WONT
4316:         JRST    DUPLX1                  ;BUT THIS WILL
    TTYSER page# 0072 next  prev
4318: ;CNCTST, CNCMOD
4319: CNCTST:
4320:         TLNE LINE,IMLIN
4321:         TLZE IOS,IMLTTY         ;Char code 3 from an IMLAC needs
4322:         CAIA
4323:         POPJ P,                 ;IMLTTY on to be a ↑C.
4324:         MOVEI CHR,600   ;INVENT INTERNAL CODE FOR ↑C.
4325: IFN FTLOGIN,<
4326: 
4327:         LDB     TAC,PJOBN
4328:         MOVE    TAC,JBTSTS(TAC)
4329: 
4330:         TLNE    TAC,JACCT               ;REG 11/26/73 NO REASON TO LET PTYS THROUGH
4331:         MOVEI   CHR,33                  ;SEND ALTMODE INSTEAD
4332: 
4333: ;       TLNN    TAC,JACCT
4334: ;       JRST    CNCTSA
4335: ;       TLNE    LINE,PTYLIN             ;DON'T HOLD UP PTY'S
4336: ;       CAIA
4337: ;       MOVEI   CHR,33
4338: ;CNCTSA:
4339: >
4340:         LDB     TAC,TIPUTR(DDB)
4341:         CAIE    TAC,600
4342:         POPJ    P,
4343: CNCTS1: PUSHJ   P,SETBFI                ;CLEAR INPUT BUFFER.
4344: 
4345: CNCMOD: MOVE    IOS,[XWD DDTM!IO!USRB,IOSUPR!MERTPO!MERTP1]
4346:         ANDCAM  IOS,DEVIOS(DDB)
4347:         MOVSI   IOS,TPMON+IOFST
4348:         IORB    IOS,DEVIOS(DDB)
4349:         POPJ    P,
    TTYSER page# 0073 next  prev
4351: ;BSECHO, DCPUTR, DELETL
4352: ;ROUTINE TO ECHO BACK-SLASH
4353: 
4354: BSECHO: PUSH    P,CHR           ;*
4355:         MOVEI   CHR,"\"
4356:         PUSHJ   P,AOJDPX
4357:         JRST    CHPOPJ
4358: 
4359: ;ROUTINE TO DECREMENT PUTR
4360: 
4361: DCPUTR:
4362:         LDB     TAC,PLSTLC              ; CHECK FOR NONE TO DELETE
4363:         CAMN    TAC,PCTR(DAT)
4364:         POPJ    P,
4365: 
4366:         MOVSI   TAC,110000
4367:         ADD     TAC,PUTR(DAT)           ;*
4368:         TLNE    TAC,400000
4369:         ADD     TAC,[XWD 337777,-1]
4370:         MOVEM   TAC,PUTR(DAT)
4371:         AOS     FCTR(DAT)
4372:         AOS     TAC,PCTR(DAT)
4373:         CAIG    TAC,TTICHR              ;*
4374:         JRST    CPOPJ1                  ;*
4375:         SUBI    TAC,TTICHR              ;*
4376:         MOVEM   TAC,PCTR(DAT)
4377:         MOVEI   TAC,STTIBF
4378:         ADDM    TAC,PUTR(DAT)           ;*
4379:         JRST    CPOPJ1
4380: 
4381: ;ROUTINE TO DELETE CURRENT LINE (↑U)
4382: 
4383: DELETL: LDB     TAC,PLSTLC              ;WHERE WAS LAST BREAK?
4384:         MOVEM   TAC,TIPCTR(DDB)         ;STORE COUNT
4385:         PUSHJ   P,TBYTEP                ;CONVERT TO A BYTE POINTER
4386:         MOVEM   TAC,TIPUTR(DDB)         ;SAVE POINTER
4387:         JRST    TRESC1                  ;GO COMPUTE TIFCTR
    TTYSER page# 0074 next  prev
4389: ;DOTALK, NOTALK
4390: IFN FTTALK,<
4391: DOTALK: ANDI    CHR,177
4392:         SKIPN   DDB,TTYTAB(LINE)
4393:         POPJ    P,0
4394: IFN FTTKBG,<
4395:         HLRZ    TAC,DDB         ;BH 3/15/74 BUG TRAP FOR INCOMPLETE LOOP
4396:         ANDI    TAC,177         ;BH JUST THE LINE NUMBER
4397:         SKIPN   TTYTAB(TAC)     ;BH TAC IS LINE # TALKER LINKED TO
4398:         JRST    DOTALX          ;BH HIS DDB GONE ALTOGETHER (CAN'T HAPPEN...)
4399:         HLRZ    HPOS,TTYTAB(TAC);BH ELSE GET HIS LINK
4400:         ANDI    HPOS,177        ;BH JUST THE LINE NUMBER
4401:         CAIN    HPOS,(LINE)     ;BH OK IF WE'RE ALL THE SAME
4402:         JRST    DOTALY          ;BH
4403:         CAIN    HPOS,(TAC)      ;BH COMPARE TO HIMSELF
4404:         JRST    DOTALX          ;BH OOPS, THEY'RE THE SAME!
4405: >;FTTKBG
4406: DOTALY: CAIE    CHR,0
4407:         CAIN    CHR,3
4408:         JRST    NOTALK
4409:         MOVE UUO,LINTAB(LINE)   ;SAVE TALKER'S XON BIT
4410:         TLZ     LINE,-1         ;NO BITS PLEASE
4411:         PUSH    P,LINE
4412: DOTAL1: LDB     LINE,PTALK
4413:         HRRZ    DDB,TTYTAB(LINE)
4414:         CAMN LINE,(P)           ;BACK TO OURSELVES YET?
4415:         JRST DOTAL2             ;YES, WE ARE SPECIAL
4416:         JUMPE   DDB,DOTAL1      ;SKIP GUYS WITHOUT DDBS
4417:         PUSH    P,CHR
4418:         PUSHJ   P,PUTCHO
4419:         MOVE CHR,(P)            ;GET CHAR
4420:         TLNN UUO,XON            ;IF TALKER HAS XON OR
4421:         CAIE CHR,15             ;IF NOT CR,
4422:         JRST DOTAL3             ;THEN NO LF
4423:         MOVEI CHR,12
4424:         PUSHJ   P,PUTCHO        ;YES, SEND IT
4425: DOTAL3: MOVE    IOS,DEVIOS(DDB)
4426:         PUSHJ   P,TYPTST
4427:         POP     P,CHR
4428:         JRST DOTAL1
4429: 
4430: DOTAL2: HLL LINE,LINTAB(LINE)   ;GET OUR CHARACTERISTICS
4431:         MOVEM CHR,(P)           ;REPLACE SAVED LINE WITH CHR
4432:         TLNN LINE,FULTWX
4433:         PUSHJ P,PUTCHO
4434:         POP P,CHR
4435:         CAIN CHR,15             ;NEED LF?
4436:         TLNE LINE,XON           ;MAYBE
4437:         JRST TYPTST             ;NO
4438:         MOVEI CHR,12
4439:         PUSHJ P,PUTCHO
4440:         JRST TYPTST
4441: 
4442: ;IF I TYPE A ↑C IN TALK RING, THEN
4443: ;ASSUME NEXT←ME←PREV
4444: ;SET NEXT←PREV
4445: ;IF NEXT=PREV, CLEAR ITS TLKRNG BIT
4446: ;SET ME←ME
4447: ;CLEAR TLKRNG BIT IN LINTAB(ME)
4448: 
4449: NOTALK: MOVEI   HPOS,0(LINE)            ;ME
4450:         TLNE    LINE,CTYLIN             ;CTY?
4451:         JRST    NOTLKB                  ;YES, CLEAR EVERYONE IN THIS RING
4452:         LDB     CHR,PTALK               ;NEXT
4453: NOTAL1: LDB     UUO,PTALK
4454:         CAMN    UUO,HPOS                ;ME←?
4455:         JRST    NOTAL2                  ;YES. LINE=PREV
4456:         MOVE    LINE,UUO                ;NO. FIND PREV
4457:         JRST    NOTAL1
4458: NOTAL2: DPB     CHR,PTALK               ;MAKE NEXT←PREV
4459:         CAIE    CHR,(HPOS)              ;NO ↑←N BREAKING SOLITAIRE TALK
4460:         CAIE    CHR,(LINE)              ;RING NOW EMPTY?
4461:         JRST    NOTAL3                  ;NO
4462: NOTLKA: MOVSI   CHR,TLKRNG              ;YES. CLR HIS BIT
4463:         ANDCAM  CHR,LINTAB(LINE)
4464:         MOVE    DDB,TTYTAB(LINE)        ;AND TELL HIM ABOUT IT BY GOLLY!!!
4465:         PUSH    P,HPOS
4466: FOR X ε {N}   {
4467:         MOVEI   CHR,"X"
4468:         PUSHJ   P,PUTCHO
4469: }                                       ;USING ANSI STANDARD TEXT 87
4470:         MOVE    IOS,DEVIOS(DDB)
4471:         PUSHJ   P,TYPTST
4472:         POP     P,HPOS
4473:         MOVE    DDB,TTYTAB(HPOS)        ;RESTORE DDB
4474:         MOVE    LINE,UUO
4475:         CAIE    LINE,(HPOS)             ;IN WHICH CASE IT HAS NEXT IN RING
4476:         JRST    NOTLKC                  ;WHICH MAY BE ME ANYWAY
4477: NOTAL3: MOVSI   CHR,TLKRNG
4478:         MOVE    LINE,HPOS               ;ME
4479:         DPB     HPOS,PTALK              ;ME←ME
4480:         ANDCAM  CHR,LINTAB(LINE)        ;CLR MY BIT
4481:         MOVEI   CHR,600                 ;GET A ↑C AGAIN
4482:         DPB     CHR,TIPUTR(DDB)         ;LOOK LIKE 2 OF THEM
4483:         HLL     LINE,LINTAB(LINE)       ;GET GOOD BITS!
4484:         TLNN    LINE,DDDLIN!DISLIN      ;FOR THESE GUYS, LEAVE IT ⊗00
4485:         MOVEI   CHR,3                   ;EVERYBODY ELSE GETS THIS
4486:         JRST    RECINA                  ;AND PROCESS IT FROM THE TOP
4487: 
4488: NOTLKB: LDB     LINE,PTALK              ;CTY: GET NEXT GUY
4489:         CAIN    LINE,(HPOS)             ;IF ONLY ME,
4490:         JRST    NOTAL3                  ;  JUST CLEAR ME QUIETLY
4491: NOTLKC: LDB     UUO,PTALK               ;SAVE HIS NEXT
4492:         DPB     LINE,PTALK              ;CLEAR HIM OUT
4493:         JRST    NOTLKA                  ;AND TELL HIM
4494: 
4495: IFN FTTKBG,<
4496: DOTALX: PUSHACS                         ;BH 3/15/74 BUG TRAP TO END OF PAGE
4497:         PUSH    P,TAC                   ;OFFENDING TALKEE
4498:         PUSH    P,DDB                   ;TALKER'S TTYTAB
4499:         ANDI    LINE,177                ;TALKER'S NUMBER
4500:         PUSH    P,LINE
4501:         PUSHJ   P,DISMES
4502:         ASCIZ /INCOMPLETE LOOP AT DOTALK!!
4503: TALKER=/
4504:         POP     P,TAC
4505:         PUSHJ   P,DISOCT
4506:         PUSHJ   P,DISMES
4507:         ASCIZ /  DDB=/
4508:         POP     P,TAC
4509:         PUSHJ   P,DISOCT
4510:         PUSHJ   P,DISMES
4511:         ASCIZ /
4512: TALKING TO /
4513:         MOVE    TAC,(P)
4514:         PUSHJ   P,DISOCT
4515:         POP     P,TAC
4516:         SKIPE   TTYTAB(TAC)
4517:         JRST    DOTLX1
4518:         PUSHJ   P,DISMES
4519:         ASCIZ /  WHO HAS NO DDB/
4520:         JRST    DOTLX2
4521: DOTLX1: PUSHJ   P,DISMES
4522:         ASCIZ /  WHO IS LINKED TO HIMSELF/
4523: DOTLX2: PUSHJ   P,DISMES
4524:         ASCIZ /
4525: FIND A WIZARD, OR TYPE POPJ 3,$X
4526: /
4527:         PUSHJ   P,DISFLU
4528:         POPACS
4529:         PUSHJ   P,DDTCAL
4530:         DPB     LINE,PTALK              ;NOW FIX IT UP
4531:         JRST    NOTALK                  ;SMASH DOPEY RING!
4532: >;FTTKBG
4533: >
    TTYSER page# 0075 next  prev
4535: ;XMTINT, XMTIN1, DPYSTR, DPYDON
4536: ;COMMON TRANSMITTER INTERRUPT FOR SCANNER AND CTY(TTY)
4537: 
4538: XMTINT:
4539:         HLL     LINE,LINTAB(LINE)       ; GET LINE CHAR.
4540:         SKIPN   DDB,TTYTAB(LINE)        ;GET DDB ADDRESS
4541:         POPJ    P,                      ;IF NONE, X BEING TYPED
4542:         MOVE    IOS,DEVIOS(DDB)         ;GET IO STATUS
4543: 
4544: XMTIN1:
4545:         LDB     DAT,PDVTIM              ;RESET HUNG COUNT
4546:         DPB     DAT,PDVCNT
4547:         MOVEI   DAT,TTOBUF(DDB)         ;GET PTR. FOR OUTPUT BUFFER.
4548:         TLNE    LINE,DISLIN!DDDLIN
4549:         JRST    DPYSTR                  ; IF A DISPLAY, GO TO OUR OWN STARTUP ROUTINE
4550: XMTI1A: CONO    PI,SCNOFF               ;KEEP TOIP AND PUTR/TAKR EQUAL
4551:         MOVE    TAC,TAKR(DAT)           ;IS OUTPUT BUFFER EMPTY?
4552:         CAME    TAC,PUTR(DAT)           ;(I.E.,HAS TAKR CAUGHT UP WITH PUTR?)
4553:         JRST    XMTIN2                  ;NO, TYPING STILL IN PROGRESS
4554: 
4555:         TRNE    IOS,MERTP1              ;MONITOR ERROR MESSAGE?
4556:         CAIE    DAT,TTOBUF(DDB)         ;OUTPUT BUFFER?
4557:         JRST    XMTIN4                  ;NO, MUST REALLY BE DONE
4558:         MOVEI   DAT,TTIBUF(DDB)         ;YES, NOW EMPTY OUT TTI BUFFER
4559:         JRST    XMTI1A
4560: 
4561: DPYSTR:   ;;INITIATE TYPEOUT ON A DISPLAY CONSOLE.
4562:         HRLI    DAT,DPYTYP              ;MAKE INTO CLOCK REQUEST ON DPYTYP(IN DPYSER),
4563:         HRRI    DAT,(LINE)              ;PASS HIM THE LINE NUMBER
4564:         JRST    DPYTIM                  ;AND ENTER IN DPY CLOCK QUEUE.
4565: 
4566: DPYDON:MOVE    IOS,DEVIOS(DSER)        ;HERE FROM DPYTYP (IN DPYSER) WHEN OUTPUT BUFFER EMPTY.
4567:         HRRZ    DDB,DSER                ; DPYSER SAVES DDB ADDRESS IN DSER
4568:         PUSHJ   P,STLNAC                ;SET UP AC LINE.
4569:         TRNN    IOS,MERTP1              ;ERROR MESSAGE TYPEOUT ?
4570:         JRST    XMTIN4                  ; NO, GO FINISH UP
4571:         CAIN    DSER,-TTOBUF(DAT)       ;YES. MUST WE STILL TYPE OUT THE INPUT BUFFER ?
4572:         JRST    DPYERT                  ;YES. GO TYPE REST OF ERROR MESSAGE FROM INPUT BUFFER.
4573:                 ;; FALL INTO XMTIN4.
    TTYSER page# 0076 next  prev
4575: ;XMTIN4, XMTIN2, LINDON, TTYPE
4576: ;HERE WHEN OUTPUT BUFFER(S) EMPTIED.
4577: 
4578: XMTIN4: MOVE    IOS,[XWD TOIP,MERTPO!MERTP1]
4579:         ANDCAB  IOS,DEVIOS(DDB)
4580:         CONO    PI,SCNON
4581:         MOVEI   CHR,0
4582:         LDB     HPOS,PJOBN              ;JOB NUMBER DDB IS ATTACHED TO
4583:         TLNN    IOS,IO
4584:         JRST    LINDON
4585:         MOVSI   IOS,IO
4586:         ANDCAB  IOS,DEVIOS(DDB)
4587:         TLNE    LINE,TLKRNG             ;KEEP DDB IF TALKING .
4588:         JRST    LINDON                  ;YES
4589:         JUMPN   HPOS,LINDON             ;LINE DONE IF DDB IS A JOB.
4590:         JRST    TTYKIL                  ;KILL TTY DDB
4591: 
4592: XMTIN2: CONO    PI,SCNON
4593:         TLNE    IOS,TTYHLD              ;IF HOLDING OUTPUT, RETURN.
4594:         POPJ    P,
4595:         PUSHJ   P,GETCHO                ;NO, GET NEXT CHAR. IN BUFFER
4596:         JUMPE   CHR,XMTIN1              ;IGNORE NULLS
4597:         JUMPL   IOS,TTYPE               ;KEEP TYPING IF INPUT I/O WAIT
4598:         TRNN    IOS,IOACT               ;ARE WE IN I/O WAIT?
4599:         JRST    TTYPE                   ;NOT IN IO WAIT
4600:         LDB     HPOS,PFITCH             ;YES, CHECK TO FIT INTO TTO BUFFER 
4601:         CAIL    HPOS,TTOCHR-50          ;ENOUGH ROOM TO ADD 8?
4602:         MOVEI   HPOS,TTOCHR-50          ;MAKE LINE BE NEARLY OUT
4603:         CAML    HPOS,FCTR(DAT)          ;IS THERE ROOM ENOUGH NOW?
4604:         JRST    TTYPE                   ;NO, KEEP TYPING
4605: 
4606: LINDON: TLNE    IOS,IOW                 ;IN IO WAIT?
4607:         TLNE    IOS,TTYIOW              ;YES, TTY INPUT WAIT?
4608:         JRST    TTYPE                   ;NO, GO TTYPE CHAR.
4609:         PUSH    P,LINE                  ;SAVE LINE
4610:         PUSHJ   P,SETIOD                ;YES, SET IO DONE (OUT OF WSYNC)
4611:         POP     P,LINE                  ;RESTORE LINE
4612:         MOVE    IOS,[XWD IOW,IOACT]     ;INDICATE NO IO ACTIVE OR WAIT
4613:         ANDCAB  IOS,DEVIOS(DDB)
4614: 
4615: TTYPE:  TLNN LINE,PTYLIN        ;DON'T TYPE IF THIS IS A PSEUDO-TTY.
4616:         JUMPN   CHR,TYPL                ;IS TYPING STILL TO BE IN PROGRESS?
4617:         POPJ P,                 ;NO.
    TTYSER page# 0077 next  prev
4619: ;TYP, TYPL, CTYP
4620: ;ROUTINE TO TYPE CHAR
4621: ;CALL   MOVE LINE,LINE NO.
4622: ;       MOVE CHR,CHARACTER
4623: ;       PUSHJ P,TYP
4624: 
4625: TYP:
4626: TYPL:  TLNE LINE,DISLIN!DDDLIN
4627:         POPJ P,                         ;DON'T DO THIS ON DPYS (MAINLY TYPX)
4628:         MOVE TAC,CHR                    ;GENERATE PARITY BIT IN CASE THIS IS A
4629:                                         ;MODEL 37
4630:         IMULI TAC,200401                ;FORM 3 COPIES OF 8 BIT CHAS.
4631:                                         ;ASSUME PARITY BIT IS 0
4632:         AND TAC,[ 11111111]             ;FORM 8 COPIES OF ORIGINAL BITS
4633:         IMUL TAC,[ 11111111]            ;ADD 8 BITS TOGETHER
4634:         TLNE TAC,10                     ;TEST PARITY OF SUM
4635:         TRO CHR,200                     ;PARITY IS ODD, MAKE IT EVEN
4636:         TLNN LINE,CTYLIN                ;NO,CONSOLE TTY?
4637:         JRST    SCNTYP                  ;TYPE CHAR.
4638: CTYP:   DATAO TTY,CHR
4639:         DPB     CHR,PLASTC
4640:         POPJ P,
    TTYSER page# 0078 next  prev
4642: ;PTYGET, PTOCK, PTICHK, PTYCLR
4643: PTYGET: ;CREATE A PTY LINE NO.
4644:         SKIPE TTYLOK            ;NO PTY'S UNDER TTYLOK
4645:         POPJ P,
4646:         MOVSI LINE,-PTYNUM      ;HOW MANY ARE AVAIABLE ?
4647:         MOVSI TAC,PTYLIN
4648:         TDNE TAC,LINTAB+PTYL0(LINE)
4649:         AOBJN LINE,.-1
4650:         JUMPG LINE,CPOPJ
4651:         ADDI LINE,PTYL0
4652:         PUSHJ P,DDBSRC          ;GET A DDB
4653:         POPJ P,                 ;NONE AVAILABLE
4654:         HRLI LINE,PTYLIN!PTYUSE!XON!FCS ;DON'T EXPAND TABS OR INVENT LF'S (XON).
4655:                                         ;ALSO FULL CHARACTER SET MODE
4656:         MOVEM LINE,LINTAB(LINE)
4657:         MOVEM ITEM,PTYJOB-PTYL0(LINE)   ;RECORD WHICH JOB OWNS THIS PTY.
4658:         XCTR    XW,[MOVEM LINE,(UUO)]   ;RETURN PTY LINE NO. TO LOSER.
4659:         JRST CPOPJ1             ;GIVE SKIP RETURN
4660: 
4661: PTOCK:    ;COME HERE WHEN A PTY OUTPUTS ANYTHING, TO WAKE UP JOBS WAITING FOR IT.
4662:         MOVE AC1,TOTAKR(DDB)
4663:         CAME AC1,TOPUTR(DDB)    ;IS THERE REALLY ANYTHING IN PTY'S OUTPUT BUF ?
4664:         TLNN LINE,PTYUSE        ;IS PTY STILL IN USE ?
4665:         JRST SETBF3     ;NO. FLUSH THE OUTPUT BUFFER.
4666:         SKIPLE TAC,PTYPTR(DDB)  ;IS SOMEONE WAITING FOR OUR OUTPUT ?
4667:         JRST PTCHK2
4668:         PUSH P,J
4669:         MOVE J,PTYJOB-PTYL0(LINE)
4670:         MOVSI AC1,INTPTO        ; GIVE PTY OUTPUT INTERRUPT
4671:         TDNE AC1,JBTIEN(J)
4672:         PUSHJ P,TTINT
4673:         POP P,J
4674:         POPJ P,
4675: 
4676: PTICHK: SKIPL TAC,PTYPTR(DDB)
4677:         POPJ P,
4678: PTCHK2: SETZM PTYPTR(DDB)
4679:         EXCH TAC,DDB
4680:         PUSHJ P,SETIOD
4681:         MOVSI AC1,IOW+TTYIOW
4682:         ANDCAM AC1,DEVIOS(DDB)
4683:         EXCH TAC,DDB
4684:         PUSHJ P,STLNAC
4685:         LDB J,PJOBN             ;SETIOD HAS CLOBBERED THIS, AND APRSER MAY CARE
4686:         POPJ P,
4687: 
4688: PTYCLR:HRRE LINE,JBTLIN(ITEM)
4689:         JUMPL LINE,PTYCL2
4690:         MOVSI TAC,SPCBRK!XON!LERSEE
4691:         HLL LINE,LINTAB(LINE)           ; GET LINE BITS BACK
4692:         TLNE LINE,PTYLIN                ; IST DAS EINE PTY?
4693:         TLZ TAC,XON                     ; YES, GIVE HIM BACK HIS LFS
4694:         ANDCAM TAC,LINTAB(LINE)
4695:         ANDCAM TAC,JBTLIN(ITEM)
4696:         PUSHJ P,TTYSRC                  ;FIND HIS TTY DDB
4697:         MOVSI TAC,STDTBL                ;AND SET HIS BREAK TABLE TO STANDARD.
4698:         HRRI TAC,ACTBTS(DDB)
4699:         BLT TAC,ACTMOD(DDB)
4700:         MOVEI TAC,NOECHO!NOECHB
4701:         ANDCAM TAC,DEVIOS(DDB)          ;TURN ECHOING BACK ON!
4702: PTYCL2: MOVEI LINE,PTYL0        ;PREPARE TO SEARCH ALL PTY'S.
4703: PTYCL1: CAIL LINE,PTYL0+PTYNUM  ;DONE ?
4704:         POPJ P,
4705:         PUSH P,LINE             ;GOD ONLY KNOWS.......
4706:         PUSH P,ITEM
4707:         PUSHJ P,PTYRL2                  ;YES. RELEASE IT FOR HIM.
4708:         POP P,ITEM
4709:         POP P,LINE
4710:         AOJA LINE,PTYCL1
    TTYSER page# 0079 next  prev
4712: ;PTYUUO, LINMAP, PTOCNT, PTIFRE
4713: PTYUUO:
4714:         JUMPE UCHN,PTYGET
4715:         XCTR XR,[HRRZ TAC,(UUO)]
4716:         TRZE TAC,400000         ;USE THIS TO MAP REAL LINES
4717:         JRST LINMAP
4718:         CAIG TAC,TTPLEN
4719:         CAILE UCHN,PTYXNO
4720:         JRST UUOERR
4721:         JUMPN TAC,PTYUU3
4722:         HRRE TAC,JBTLIN(ITEM)   ;IF HE ASKS FOR LINE 0,
4723:         JUMPL TAC,CPOPJ ;NOT IF DETACHED.
4724:         JRST PTYUU2             ; GIVE HIM HIS OWN TTY.
4725: PTYUU3: CAIL TAC,PTYL0  ;IS IT A PTY ?
4726:         CAME ITEM,PTYJOB-PTYL0(TAC)     ;YES. DOES HE OWN IT ?
4727:         CAIN UCHN,PTRLCD        ;NO. AN ERROR UNLESS HE IS MERELY RELEASING IT.
4728: PTYUU2: SKIPA LINE,LINTAB(TAC)
4729:         JRST UUOERR             ;SORRY, THE LINE YOU HAVE REQUESTED IS NOT YOURS AT THIS TIME.
4730:         HRRI LINE,(TAC)
4731:         ADDI UUO,1
4732:         HRLI UUO,(<POINT 36,0,35>)      ;MAKE FULL-WORD BYTE PTR. IN UUO.
4733:         SKIPE DDB,TTYTAB(LINE)  ;GET LOC. OF HIS DDB.
4734:         JRST PTYUU4
4735:         PUSHJ P,DDBSRC          ;NO DDB, SO GET HIM ONE.
4736:         JRST UUOERR             ;NONE AVAILABLE.
4737: PTYUU4: SKIPG PTYDIS(UCHN)      ;LEGAL FOR TTY'S?
4738:         TLNE LINE,PTYLIN        ;OR PTY?
4739:         JRST @PTYDIS(UCHN)
4740:         JRST UUOERR             ;SOMETIMES YOU HAVE TO BE A PTY TO DO A PTY-UUO!
4741: 
4742: LINMAP: CAILE TAC,TTPLEN
4743:         JRST UUOERR
4744:         MOVE AC1,JBTPRV(J)
4745:         TLNE AC1,MESPRV
4746:         JRST PTYUU2             ;ALL OK NOW
4747:         SKIPN DDB,TTYTAB(TAC)
4748:         JRST UUOERR
4749:         LDB AC1,PJOBN
4750:         CAMN AC1,J
4751:         JRST PTYUU2
4752:         JRST UUOERR
4753: 
4754: DEFINE UUOS{FOR X IN(PTYGET,<PTYREL,PTRLCD←←.-PTYDIS>,PTIFRE,<PTOCNT>
4755: ,<PTRD1S,400000>,<PTRD1W,400000>,PTWR1S,<PTWR1W>
4756: ,<PTRDS,400000>,PTWRS7,PTWRS9,<PTGETL,,GETLN1>
4757: ,<PTSETL,,SETLIN>,<PTLOAD,,PTLLED>,PTJOBX)}
4758: 
4759: UUOMAC PTYDIS,PTYUUO
4760: PTYXNO←←UUOCNT-1
4761: 
4762: PTOCNT: SKIPA CHR,TOFCTR(DDB)
4763: PTIFRE: SKIPA CHR,TIFCTR(DDB)
4764:         SUBI CHR,TTOCHR-1       ;GET -(NO. OF CHRS. IN BUFFER).
4765:         SUBI CHR,1              ;COUNT CAN ONLY GO TO 1 NOT 0.
4766: PTSTOR: XCTR XW,[MOVMM CHR,(UUO)]
4767:         POPJ P,
    TTYSER page# 0080 next  prev
4769: ;PTYREL, PTRD1S, PTRD1W, PTWAIT
4770: PTYREL: TLNE LINE,PTYLIN        ;RELEASE THE PTY, IF IT REALLY IS ONE.
4771: PTYRL2: CAME ITEM,PTYJOB-PTYL0(LINE)    ;DOES THIS JOB OWN THIS PTY ?
4772:         POPJ P,
4773:         SKIPN DDB,TTYTAB(LINE)  ;THIS IS NEEDED IF WE CAME FROM PTYCLR.
4774:         JRST LINCLR             ;CLEAR LINE BITS AND RETURN.
4775:         PUSHJ P,XMTIN4          ;FINISH OUTPUT.
4776:         PUSHJ P,TSETBF          ;CLEAR BOTH ITS BUFFERS.
4777:         SETZM PTYJOB-PTYL0(LINE)        ;CLEAR OWNERSHIP FLAG.
4778:         MOVSI TAC,PTYUSE        ;MARK PTY AS NO LONGER USED, SO DDB WILL BE
4779:         ANDCAM TAC,LINTAB(LINE) ;KILLED BY TTYKIL.
4780:         LDB J,PJOBN             ;GET JOB ON THIS PTY
4781:         JUMPE J,.+2             ;IF ANY
4782:         PUSHJ P,INTKILL         ;NOW KEEP HIM FROM FUTZING AROUND
4783:         MOVE UUO,[BYTE(7)3,3,"K",12,0]
4784:         XCTR    XW,[MOVEM UUO,JOBTM1]   ;PUT IT IN USER CORE.
4785:         MOVE UUO,[POINT 7,JOBTM1]       ;THIS WILL BE RELOCATED.
4786:         PUSHJ P,PTWR2                   ;SEND JOB ↑C ↑C K<LF>.
4787:         POPJ P,
4788: 
4789: PTRD1S: MOVE IOS,DEVIOS(DDB)    ;GET STATUS WORD.
4790:         PUSHJ P,XMTIN1
4791:         XCTR    XDB,[DPB CHR,UUO]               ;GIVE CHAR. TO LOSER.
4792:         JUMPE CHR,CPOPJ
4793:         JRST CPOPJ1
4794: 
4795: PTRD1W: PUSHJ P,PTRD1S
4796:         SKIPA UCHN,DDB
4797:         POPJ P,
4798:         PUSHJ P,TTYGET
4799:         HRRZM DDB,PTYPTR(UCHN)
4800:         MOVSI IOS,IOW!TTYIOW!DDTM
4801:         TLNE LINE,PTYWAK        ;DO WE WANT TO HEAR TTY INPUT ?
4802:         IORM IOS,DEVIOS(DDB)
4803:         PUSHJ P,PTWAIT
4804:         SETZM PTYPTR(DDB)
4805:         PUSHJ P,PTRD1S
4806:         POPJ P,
4807:         POPJ P,
4808: 
4809: PTWAIT: MOVEI TAC,IOWQ
4810:         MOVNM TAC,JOBQUE(J)
4811:         MOVE DDB,UCHN   ;RECOVER DDB FOR PTY.
4812:         PUSHJ P,STLNAC                  ;RESTORE LINE (CLOBBERED BY TTYGET).
4813:         JRST WSCHED
    TTYSER page# 0081 next  prev
4815: ;PTWR1S, PTLL3, PTWR1W, PTRDS, PTWRS7, PTWRS9
4816: PTWR1S: MOVEI CHR,1
4817:         CAML CHR,TIFCTR(DDB)            ;IS THERE ROOM (>1 NOT 0).
4818:         POPJ P,
4819:         AOS (P)                         ;THERE IS ROOM FOR THE CHR., SO WE WILL SKIP.
4820:         XCTR XLB,[LDB CHR,UUO]
4821:         LDB UCHN,[POINT 2,CHR,28]
4822: PTLL3:  LDB DSER,[POINT 7,CHR,35]       ;SIMULATE KBDINT, IN CASE THIS PTY IS REALLY A DPY.
4823:         CAIL DSER,"A"
4824:         CAILE DSER,"Z"
4825:         JRST .+2
4826:         TRO DSER,40
4827:         MOVEI AC2,
4828:         PUSHJ P,STLNAC          ;IN CASE KBDED IS AROUND CLOBBERING THINGS.
4829:         MOVE TAC,LINTAB(LINE)   ;SET UP ESCAPE BITS
4830:         DPB LINE,[PUNITS6,,TAC];BUT NULLIFY MAPPING
4831:         CONO PI,SCNOFF
4832:         PUSHJ P,PTYREC          ;PRETEND CHR. HAS JUST BEEN TYPED IN.
4833:         JRST TYPT1              ;TURN ON PI AND POPJ.
4834: 
4835: PTWR1W: TLNE LINE,IMLIN         ;IMLAC FORWARD-SPACE KLUDGE
4836:         JRST IMWR1W
4837: IMWR10: PUSHJ P,PTWR1S          ;WRITE A CHAR.
4838:         SKIPA UCHN,DDB          ;DIDN'T GO. LET'S WAIT A WHILE.
4839:         POPJ P,                 ;ALL DONE.
4840:         PUSHJ P,TTYGET
4841:         HRROM DDB,PTYPTR(UCHN)
4842:         PUSHJ P,PTWAIT
4843:         JRST PTWR1W
4844: 
4845: IMWR1W: XCTR XLB,[LDB CHR,UUO]  ;IMLAC...
4846:         CAIN CHR,211            ;<CONTROL>TAB?
4847:         JRST IMWR11
4848:         CAIE CHR,240            ;<CONTROL>SPACE?
4849:         JRST IMWR10             ;NEITHER.  BACK TO OLD CODE.
4850:         MOVE CHR,[ASCID/ε↓/]    ;CTL-SPACE.  COMMAND TO MOVE FORWARD 1.
4851:         CAIA
4852: IMWR11: MOVE CHR,[ASCID/ε}/]    ;CTL-TAB.  MOVE FORWARD A BUNCH.
4853:         PUSHJ P,TTYFNU
4854:         JRST FIVOUT             ;SEND THE COMMAND.
4855: 
4856: ; PTRDS, PTWRS7, PTWRS9 CHANGED 3-30-71 TO USE LH (ADR+1) AS BYTE
4857: ; POINTER SPEC IF NON-ZERO ------ DCS
4858: 
4859: PTRDS:  XCTR    XR,[MOVE UUO,(UUO)]     ;GET ADDRESS OF BUFFER IN LOSER CORE.
4860:         TLZN    UUO,7777        ;CLEAR SIZE FIELD, CHECK FOR BP THERE --DCS
4861:         HRLI    UUO,440700      ;NONE, GIVE 7-BIT PTR TO FIRST CHAR --DCS
4862:         TLO     UUO,700         ;ASSURE CORRECT SIZE FIELD, AT LEAST--DCS
4863:         IBP     UUO             ;STUPID SAIL!
4864: PTRDSA: PUSHJ P,PTRD1W  ;WAIT FOR AT LEAST ONE CHAR. TO APPEAR.
4865: PTRDS2: IBP UUO
4866:         PUSHJ P,PTRD1S  ;GET ANY FURTHER CHARS.
4867:         POPJ P,         ;NO MORE.
4868:         JRST PTRDS2     ;MAYBE MORE.
4869: 
4870: PTWRS7: TLCA UUO,444300 ;MAKE 7-BIT PTR. ...
4871: PTWRS9: TLC UUO,445500  ;MAKE 9-BIT PTR.
4872:         HLR     CHR,UUO ;SAVE BP SPEC FOR FIRST CHAR--DCS
4873:         XCTR    XR,[MOVE UUO,(UUO)]     ;GET ADDRESS OF BUFFER IN LOSER CORE.
4874:         TLZN    UUO,7777        ;CLEAR SIZE AND INDEX, CHECK--DCS
4875:         HRL     UUO,CHR         ;ZERO, PROVIDE CORRECT PTR --DCS
4876:         DPB     CHR,[POINT 12,UUO,17];ASSURE CORRECT SIZE FIELD--DCS
4877: PTWR2:  XCTR    XLB,[ILDB CHR,UUO]
4878:         JUMPE CHR,STLNAC        ;DONE IF NULL
4879:         PUSHJ P,PTWR1W  ;GIVE NEXT CHAR. TO PTY.
4880:         JRST PTWR2      ;LOOP UNTIL WE SEE A NULL.
4881: 
    TTYSER page# 0082 next  prev
4883: ;PTJOBX
4884: PTJOBX: LDB TAC,PJOBN           ;GET JOB WHICH IS ON THIS PTY
4885:         XCTR XR,[MOVE TAC1,(UUO)]       ;GET COMMAND
4886:         TLNN TAC1,770000        ;IS IT SIXBIT OR DIRECT INDEX?
4887:         JRST PTJDIR             ;DIRECT
4888:         MOVEI AC1,PTJLEN        ;LENGTH OF TABLE
4889:         CAME TAC1,PTJTAB-1(AC1) ;MATCH?
4890:         SOJG AC1,.-1
4891:         MOVE TAC1,AC1
4892: PTJDIR: JUMPLE TAC1,UUOERR
4893:         CAILE TAC1,PTJLEN       ;IS IT IN TABLE?
4894:         JRST UUOERR             ;NO
4895:         HRRZ TAC1,PTJDIS-1(TAC1)        ;GET DISPATCH
4896:         JRST (TAC1)             ;AND DISPATCH
4897: 
4898: DEFINE NAMES
4899: <       C       HALT,PTJHLT,0
4900:         C       CONT,PTJCON,0
4901:         C       DOFF,PTDOFF,0
4902:         C       DON,PTDON,0
4903:         C       LOGIN,PTLOGN,0
4904:         C       IWAITS,PTIWTS,0
4905:         C       CLRBFI,PTCLRB,0
4906: >
4907: DEFINE C(A,B,BITS)
4908: <       XWD BITS,B
4909: >
4910: PTJDIS: 
4911: XLIST
4912:         NAMES
4913: LIST
4914: PTJLEN←←.-PTJDIS
4915: DEFINE C(A,B,BITS)
4916: <       SIXBIT/A/
4917: >
4918: PTJTAB: 
4919: XLIST
4920: NAMES
4921: LIST
    TTYSER page# 0083 next  prev
4923: ;PTJHLT, PTJCON, PTIWTS, PTCLRB
4924: ;HALT JOB RUNNING ON THIS PTY
4925: PTJHLT: JUMPE TAC,CPOPJ
4926:         PUSH P,J                ;SAVE OURSELVES FIRST.
4927:         MOVE J,TAC              ;NOW DO IT TO HIM
4928:         CAMN J,STUSER           ;SYSTEM TAPE USER?
4929:         JRST HLTOK0
4930:         PUSHJ P,STOPCK  ;NO, OK TO STOP?
4931:         CAIA
4932:         JRST HLTOK      ;YES
4933: NOTOK:  POP P,J
4934:         PUSHJ P,WSCHED  ;WAIT A WHILE
4935:         JRST PTJHLT
4936: HLTOK0: SKIPN JBTADR(J)
4937:         JRST HLTOK1
4938:         PUSHJ P,ANYACT
4939:         JRST NOTOK
4940: HLTOK1: PUSHJ P,ESTOP
4941:         POP P,J
4942:         JRST CPOPJ1             ;SUCCESS RETURN
4943: HLTOK:  PUSHJ P,STOP1
4944:         POP P,J
4945:         JRST CPOPJ1             ;SUCCESS RETURN
4946: 
4947: ;CONTINUE THE JOB RUNNING ON THIS PTY
4948: 
4949: PTJCON: JUMPE TAC,CPOPJ
4950:         PUSH P,J
4951:         MOVE J,TAC
4952:         MOVM TAC,JOBQUE(J)
4953:         CAIE TAC,STOPQ          ;THIS IS ONLY PLACE YOU CAN CONTINUE FROM
4954:         JRST NOCONT
4955:         MOVE TAC,JBTSTS(J)
4956:         TLNE TAC,JERR
4957:         JRST NOCONT
4958:         MOVNI TAC,RUNQ
4959:         MOVEM TAC,JOBQUE(J)
4960:         PUSHJ P,SETRUN
4961:         AOS -1(P)               ;SUCCESS RETURN
4962: NOCONT: POP P,J
4963:         JRST CPOPJ1             ;SUCCESS RETURN
4964: 
4965: ;SKIP IF PTY IS WAITING FOR INPUT
4966: 
4967: PTIWTS: MOVE IOS,DEVIOS(DDB)
4968:         TLNE IOS,TPMON          ;MONMODE OR USRMODE?
4969:         JRST PTIWT1
4970:         JUMPL IOS,CPOPJ1        ;USER MODE, CHECK TTYIOW BIT
4971:         POPJ P,                 ;IT WAS OFF
4972: 
4973: PTIWT1: LDB LINE,PUNIT          ;GRUMBLE, GRUMBLE, PTJOBX MUNGS "TAC1"!!
4974:         MOVE TAC,TTYTAB(LINE)   ;MONITOR MODE, GOBBLE TTYTAB
4975:         TLNN TAC,COMBIT!DLYBIT
4976:         AOS (P)
4977:         POPJ P,
4978: 
4979: ;PTJOBX [N ↔ SIXBIT /CLRBFI/] -- DO CLRBFI FOR TTYN
4980: PTCLRB: JRST SETBFI             ;YES, I KNOW THIS WASTES A CELL AND A CYCLE
    TTYSER page# 0084 next  prev
4982: ;PTDON, PTDOFF,PTLOGN,IMLOAD
4983: ; ROUTINES TO SET DUPLEXING OF PTY
4984: 
4985: PTDON:  MOVEI IOS,NOECHO
4986:         ANDCAB IOS,DEVIOS(DDB)
4987:         POPJ P,
4988: 
4989: PTDOFF: MOVEI IOS,NOECHO
4990:         ORB IOS,DEVIOS(DDB)
4991:         POPJ P,
4992: 
4993: ;START A NEW JOB ON A PTY.  USES FORK CODE.
4994: 
4995: PTLOGN: JUMPN TAC,PTLGN1        ;LOSE IF THERE'S A JOB ALREADY
4996:         HRLM J,(P)              ;SAVE OUR JOBNUM
4997:         PUSHJ P,INIJOB          ;GOBBLE A NEW JOB
4998:         JRST PTLGN0             ;SORRY, NO JOBS
4999:         JRST PTLGN0             ;THIS CAN'T HAPPEN (IT SAYS HERE)
5000:         PUSHJ P,FORKC           ;THIS COPIES THE OLD JOB'S STUFF
5001:         MOVEI TAC,(J)           ;TO RETURN IT TO LOSER
5002:         AOSA    (P)
5003: PTLGN0: MOVEI   TAC,0
5004: PTLGN1: XCTR    XW,[MOVEM TAC,(UUO)]
5005:         POPJ    P,
5006: 
5007: ;DO A PTLOAD TO AN IMLAC
5008: 
5009: IMLOAD: PUSHJ P,TTYFNU
5010:         XCTR    XR,[MOVE UUO,(UUO)]     ;GET GUY'S PTR.
5011:         TLNN    UUO,-1                  ;IS IT ALREADY (PRESUMABLY) A BYTE PTR. ?
5012:         HRLI    UUO,440700              ;NO. MAKE IT ONE.
5013: IMLOD0: MOVE CHR,[ASCID/0/]             ;Load command is "0"+no. of chars.
5014:         MOVE TAC,[POINT 7,CHR,6]
5015: IMLOD1: XCTR    XLB,[ILDB AC3,UUO]      ;Get a char,
5016:         JUMPE AC3,IMLOD2                ;end on a null.
5017:         ADD CHR,[BYTE (7)1]             ;Count the chars.
5018:         IDPB AC3,TAC                    ;Stuff char into the command.
5019:         TLNE TAC,760000                 ;Full word (4 chars)?
5020:         JRST IMLOD1                     ;No.  Do it again.
5021:         PUSHJ P,FIVOUT                  ;Send those 4 to the IMLAC
5022:         JRST IMLOD0                     ;and keep going.
5023: IMLOD2: CAME CHR,[ASCID/0/]             ;Done.  Put out the last few chars.
5024:         PUSHJ P,FIVOUT
5025:         MOVE CHR,[ASCID/¬/]             ;Command to move to beginning of
5026:         JRST FIVOUT                     ;line and return to normal.
    TTYSER page# 0085 next  prev
5028: ;PHONE DIALER LIVES HERE
5029: IFE DILNUM,<DIAL:JRST UUOERR>;IF NO DIALER, UUOERR
5030: IFN DILNUM,<
5031: ;DIALER BITS AND DEFINITIONS
5032: DIL0TT←←11              ;TTY11 IS DIALER 0
5033: 
5034: ;CONI BITS
5035: DILDS1←←4000            ;DATASET ANSWERED OR DIALED END OF NUMBER CODE
5036: DILDS0←←2000            ;DATASET HUNG-UP
5037: DILBSY←←1000            ;DIALER BUSY
5038: DILOK←←400              ;DIALER OK (NOT TIMED OUT)
5039: DILDSS←←200             ;CONNECTED
5040: DILVMD←←100             ;IN VOICE MODE
5041: DILPWR←←40              ;POWER FAIL
5042: 
5043: ;CONO BITS
5044: DILCLR←←40              ;CLEAR INTERRUPT CONDITION
5045: DILHUP←←20              ;HANG UP
5046: DILENB←←10              ;ENABLE INTERRUPT
5047: 
5048: ;DATAO BITS (LEFT HALF)
5049: DAREA←←4000             ;DIAL AREA CODE
5050: DVOICE←←2000            ;GO TO VOICE MODE ON DSS←1
5051: 
5052: ;DIALER INITIALIZE ROUTINE
5053: DILINI: CONO DIL,DILCLR!DILHUP!DILENB!DILCHN    ;INIT HARDWARE
5054:         SETZM DILZBG                    ;BEGIN ZERO OF DIALER DATA
5055:         MOVE TAC,[DILZBG,,DILZBG+1]
5056:         BLT TAC,DILZND                  ;AND ZERO TO END
5057:         POPJ P,
5058: 
5059: DILTRL: MOVSI AC1,-DILNUM
5060: DILTR1: HRRZ TAC,DILTTY(AC1)
5061:         CAIE TAC,(LINE)
5062:         AOBJN AC1,DILTR1
5063:         JUMPGE AC1,CPOPJ
5064:         PUSH P,LINE
5065:         HRRZ LINE,AC1
5066:         SKIPE DILJOB(LINE)
5067:         PUSHJ P,RELDIL  ;RELEASE DIALER
5068:         POP P,LINE
5069:         POPJ P,
    TTYSER page# 0086 next  prev
5071: ;DIAL UUO
5072: ;CALL
5073: ;       MOVEI AC,ADDR
5074: ;       DIAL AC,
5075: ;       <ERROR RETURN, AC CONTAINS STATUS BITS>
5076: ;       <SUCCESS, AC CONTAINS ANY DATA RETURNED>
5077: ;
5078: ;ADDR:  DIALER #,,FUNCTION CODE
5079: ;       SEE INDIVIDUAL CALL FOR REST OF DATA
5080: 
5081: DILER0: JSP TAC,DILERR
5082: DILER1: JSP TAC,DILERR
5083: DILER2: JSP TAC,DILERR
5084: DILER3: JSP TAC,DILERR
5085: DILER4: JSP TAC,DILERR
5086: 
5087: DILERR: SUBI TAC,DILER0+1
5088:         HRRZ TAC,TAC
5089: DILSTT: XCTR XW,[MOVEM TAC,(UCHN)]      ;STORE ERROR CODE BACK IN AC
5090:         POPJ P,
5091: 
5092: ;ERROR CODES FOR ALL DIAL UUO'S
5093: ;ERROR 0 -- ILLEGAL DIALER #
5094: ;ERROR 1 -- DON'T OWN DIALER
5095: ;ERROR 2 -- DON'T MEET DILOWN CONDITIONS
5096: ;ERROR 3 -- DIALER BUSY
5097: ;ERROR 4 -- DIALING FAILURE
5098: 
5099: DIAL:  XCTR XR,[HRRZ UUO,(UCHN)]       ;FETCH POINTER TO ARG BLOCK
5100:         XCTR XR,[HLRZ LINE,(UUO)]       ;GET DIALER NUMBER
5101:         CAIL LINE,DILNUM                ;LEGAL?
5102:         JRST DILER0                     ;NO, ERROR 0
5103:         XCTR XR,[HRRZ DSER,(UUO)]       ;GET FUNCTION CODE
5104:         CAIL DSER,MXDLCD                ;LEGAL FUNCTION CODE?
5105:         JRST UUOERR                     ;NO
5106:         CAME J,DILJOB(LINE)             ;HIS?
5107:         JUMPN DSER,DILER1               ;NO, ERROR 1 (UNLESS DILGET)
5108:         JRST @DILDIS(DSER)              ;YES, CALL ROUTINE
5109: 
5110: DILDIS: DILGET                          ;0 GET DIALER
5111:         DILSTA                          ;1 GET DIALER STATUS
5112:         DILDIL                          ;2 DIAL A NUMBER
5113:         DILHNG                          ;3 HANG UP
5114:         DILREL                          ;4 RELEASE
5115: MXDLCD←←.-DILDIS
5116: 
5117: ;CODE 0 GET DIALER
5118: DILGET: CAMN J,DILJOB(LINE)             ;DOES HE OWN IT?
5119:         JRST CPOPJ1                     ;ALREADY HAS IT, SUCCESS
5120:         SKIPE DILJOB(LINE)              ;DOES ANYONE OWN IT?
5121:         JRST DILER1                     ;YES, DON'T OWN ERROR
5122:         XCT DILOWN(LINE)                ;CHECK OTHER CONDITIONS
5123:         JRST DILER2                     ;LOSE
5124:         MOVEM J,DILJOB(LINE)            ;CLAIM IT
5125:         JRST CPOPJ1
5126: 
5127: DILTTY: 400000,,DIL0TT                  ;TTY NUMBER FOR THIS DIALER (SIGN BIT MEANS CONNECTED TO AD/DA)
5128: 
5129: DILOWN: PUSHJ P,DIL0CK                  ;CHECK ROUTINE FOR DIALER 0
5130: 
5131: DIL0CK: MOVE DDB,DILTTY(LINE)
5132:         SKIPN DDB,TTYTAB(DDB)           ;CHECK TTY FOR DIALER
5133:         POPJ P,                         ;NO TTY THERE AT ALL
5134:         LDB TAC,PJOBN
5135:         CAME TAC,J                      ;IS IT HIS?
5136:         POPJ P,                         ;NO
5137:         MOVE TAC,DEVMOD(DDB)
5138:         TRNE TAC,ASSPRG                 ;DOES HE HAVE IT INITED?
5139:         AOS (P)                         ;YES, SUCCESS
5140:         POPJ P,
5141: 
5142: ;CODE 1 GET STATUS
5143: DILSTA: CONI DIL,TAC                    ;GET CURRENT STATUS
5144:         HRL TAC,DILCNI(LINE)            ;LAST I-LEVEL CONI IN LEFT HALF
5145:         AOS (P)                         ;ALWAYS SUCCESSFUL HERE
5146:         JRST DILSTT                     ;RETURN STATUS BITS IN AC
5147: 
5148: ;CODE 2 DIAL A NUMBER
5149: DILDIL: CONSZ DIL,DILBSY
5150:         JRST DILER3                     ;DIALER BUSY
5151:         CONSZ DIL,DILPWR                ;IS DIALER POWER OK?
5152:         JRST DILER4                     ;NO, GIVE HIM AN ERROR RIGHT AWAY
5153:         XCTR XR,[MOVE TAC,2(UUO)]       ;PICKUP DATAO WORD
5154: IFN 0,<;ENABLE WHEN AD/DA CONNECTED
5155:         TLNE TAC,DVOICE                 ;ATTEMPTING VOICE MODE?
5156:         SKIPL DILTTY(LINE)              ;CONNECTED TO AD/DA?
5157:         JRST DILNM1
5158: ;CHECK AD/DA OWNERSHIP HERE
5159: DILNM1:
5160: >;IFN 0
5161:         XCTR XR,[MOVE AC1,1(UUO)]       ;PICKUP CONO WORD
5162:         ANDI AC1,777700                 ;JUST AREA CODE
5163:         CAIN AC1,4B21!1B25!5B29         ;AREA 415?
5164:         TLZ TAC,DAREA                   ;YES, DON'T DIAL AREA CODE
5165:         CONO PI,DILOFF                  ;DISABLE DIALER CHANNEL
5166:         CONO DIL,DILCLR!DILENB!DILCHN(AC1)      ;SETUP
5167:         DATAO DIL,TAC                   ;AND GO
5168: DILWAT: MOVNI TAC,IOWQ
5169:         MOVEM TAC,JOBQUE(J)
5170:         PUSHJ P,REQUE
5171:         MOVE AC1,[JRST DILING]          ;DISPATCH FOR I-LEVEL
5172:         MOVEM AC1,DILIDS(LINE)
5173:         SETZM DILCNI(LINE)              ;CLEAR CONI BITS FOR CHECK
5174:         CONO PI,DILON
5175:         PUSHJ P,WSCHED                  ;WAIT FOR DIALER
5176:         CONO PI,DILOFF                  ;INTERLOCK
5177:         SKIPN TAC,DILCNI(LINE)          ;GET CONI BITS
5178:         JRST DILWAT
5179:         CONO PI,DILON
5180:         TRC TAC,DILDS1!DILOK!DILDSS     ;ALL THESE SHOULD BE ON
5181:         TRCN TAC,DILDS1!DILOK!DILDSS
5182:         TRNE TAC,DILDS0!DILPWR          ;THESE SHOULD BE OFF
5183:         CAIA
5184:         JRST DILSTAT                    ;OK, RETURN STATUS
5185:         CONO DIL,DILHUP!DILENB!DILCHN   ;HANG IT IN YOUR EAR
5186:         JRST DILER4                     ;DIALER ERROR
5187: 
5188: ;CODE 3 HANG UP
5189: DILHNG: CONO DIL,DILHUP!DILENB!DILCHN   ;HANG IT IN YOUR EAR
5190:         JRST DILSTAT                    ;RETURN STATUS
5191: 
5192: ;CODE 4 RELEASE DIALER
5193: DILREL: PUSHJ P,RELDIL
5194:         JRST DILSTAT                    ;RETURN STATUS
5195: 
5196: RELDIL: SETZM DILIDS(LINE)              ;CLEAR I-LEVEL DISPATCH
5197:         CONO DIL,DILHUP!DILENB!DILCHN   ;HANG IT IN YOUR EAR
5198:         SETZM DILJOB(LINE)
5199:         POPJ P,
    TTYSER page# 0087 next  prev
5201: ;DIALER INTERRUPTS COME HERE
5202: DILINT:MOVEM LINE,DILLIN
5203:         MOVEI LINE,0                    ;ONLY ONE LINE FOR NOW
5204:         MOVEM TAC,DILTAC
5205:         CONI DIL,TAC                    ;GET STATUS BITS
5206:         MOVEM TAC,DILCNI(LINE)          ;LATEST CONI BITS
5207:         SKIPE DILIDS(LINE)              ;THIS DIALER ACTIVE?
5208:         XCT DILIDS(LINE)                ;DISPATCH TO DIALER ROUTINE OR EXIT
5209: DILXIT: CONSO DIL,DILBSY                ;DIALER BUSY?
5210:         JRST DILXT1                     ;NO, DON'T CHECK FOR HANGUP
5211:         CONSO DIL,DILOK                 ;IF NOT OK
5212:         CONO DIL,DILHUP                 ;HANG UP
5213: DILXT1: CONO DIL,DILCLR!DILENB!DILCHN   ;CLEAR INTERRUPT, ENABLE, SET CHANNEL
5214:         MOVE TAC,DILTAC
5215:         MOVE LINE,DILLIN
5216:         JEN @DILCHL
5217: 
5218: DILING: TRNE TAC,DILDS1                 ;SHOULD HAVE JUST CONNECTED
5219:         TRNN TAC,DILDSS                 ;AND STILL BE CONNECTED
5220:         TDZA TAC,TAC                    ;NOT CONNECTED, IDLE STATE
5221:         MOVE TAC,[JRST DILACT]          ;CONNECTED, SET TO ACTIVE STATE
5222:         MOVEM TAC,DILIDS(LINE)          ;SET DISPATCH
5223:         MOVEM J,DILJ
5224:         MOVE J,DILJOB(LINE)
5225:         MOVM TAC,JOBQUE(J)
5226:         CAIE TAC,IOWQ                   ;STILL WAITING FOR US?
5227:         JRST DILIN1
5228:         MOVNI TAC,RUNQ
5229:         MOVEM TAC,JOBQUE(J)
5230:         MOVEI TAC,QJOB(J)
5231:         CONO PI,PIOFF
5232:         SKIPE (TAC)
5233:         JRST DILIN0
5234:         EXCH TAC,QJOB
5235:         HRROM TAC,@QJOB
5236: DILIN0: CONO PI,PION
5237: DILIN1: MOVE J,DILJ
5238:         JRST DILXIT
5239: 
5240: DILACT: TRNE TAC,DILOK                  ;IF NOT OK,
5241:         TRNE TAC,DILDS0!DILPWR          ;OR ANY ERRORS
5242:         XCT DILERP(LINE)                ;THEN REPORT ERROR
5243:         JRST DILXIT                     ;I WONDER WHAT WAS WRONG?
5244: 
5245: DILERP: JRST DILERT                     ;REPORT TO TTY
5246: 
5247: DILERT: MOVE TAC,DILTTY(LINE)
5248:         SKIPN TAC,TTYTAB(TAC)           ;JUST IN CASE
5249:         JRST DILXIT                     ;FOO
5250:         MOVEM J,DILJ
5251:         MOVSI J,IODERR
5252:         IORM J,DEVIOS(TAC)              ;FLAG ERROR TO TTY
5253:         MOVE J,DILJ
5254:         JRST DILXIT
5255: >;IFN DILNUM
 EOF: TTYSER end-of-file. cnt=86